Force a stable sorted ordering of cros subcommands.
Dictionaries aren't stable in ordering, and argparse doesn't force
sorting/ordering of the subcommands added to it- meaning the --help
text would be unstable.
So force a sorted ordering to make it consistent/sane.
BUG=None
TEST=None.
Change-Id: Ie2973048f259241d0a27a1b230092f5c3d43aa87
Reviewed-on: https://gerrit.chromium.org/gerrit/39240
Tested-by: Brian Harring <ferringb@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: David James <davidjames@chromium.org>
diff --git a/scripts/cros.py b/scripts/cros.py
index a01c2c6..532897d 100644
--- a/scripts/cros.py
+++ b/scripts/cros.py
@@ -13,7 +13,7 @@
return parser
subparsers = parser.add_subparsers(title='cros commands')
- for cmd_name, class_def in my_commands.iteritems():
+ for cmd_name, class_def in sorted(my_commands.iteritems(), key=lambda x:x[0]):
sub_parser = subparsers.add_parser(cmd_name, help=class_def.__doc__)
class_def.AddParser(sub_parser)