Add support for new-style registration codes.
BUG=chrome-os-partner:27661
TEST=Unit tests
Change-Id: Ia180f8927b167829b37d9ca7fc7b6c54cb16704b
Reviewed-on: https://chromium-review.googlesource.com/192546
Reviewed-by: Jon Salz <jsalz@chromium.org>
Commit-Queue: Jon Salz <jsalz@chromium.org>
Tested-by: Jon Salz <jsalz@chromium.org>
diff --git a/py/tools/regcode.py b/py/tools/regcode.py
new file mode 100755
index 0000000..a03ae79
--- /dev/null
+++ b/py/tools/regcode.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""A command-line tool for reg code handling."""
+
+
+import factory_common # pylint: disable=W0611
+from cros.factory.hacked_argparse import CmdArg, Command, ParseCmdline
+from cros.factory.test.registration_codes import RegistrationCode
+
+
+@Command('decode',
+ CmdArg('regcode', metavar='REGCODE',
+ help='Encoded registration code string'))
+def Decode(options):
+ reg_code = RegistrationCode(options.regcode)
+ if reg_code.proto:
+ print reg_code.proto
+ else:
+ print reg_code
+
+
+def main():
+ options = ParseCmdline('Registration code tool.')
+ options.command(options)
+
+
+if __name__ == '__main__':
+ main()