cros: Fix `cros --help`
cros --help currently print:
usage: cros [--log-level {fatal,critical,error,warning,notice,info,debug}]
...
cros: error: too few arguments
And return code is 1, since it doesn't know the --help argument.
Also the output is at stderr and is not the same format that bash
completion is expecting.
Change add_help to always use the default value (which is True) fixes
this.
BUG=chromium:1029239
TEST=manually,
`cros --help`, `cros flash --help`, `cros flash usb:// <image>` works.
TEST=./scripts/run_tests ./scripts/cros_unittest
Change-Id: I52de81443191af2944436cdb4c948ae205bd945f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1940036
Commit-Queue: Pi-Hsun Shih <pihsun@chromium.org>
Tested-by: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cros.py b/scripts/cros.py
index 8368b29..cadba28 100644
--- a/scripts/cros.py
+++ b/scripts/cros.py
@@ -30,10 +30,7 @@
Returns:
A commandline.ArgumentParser object.
"""
- # We need to omit help for the base parser so that we're able to parse out the
- # subcommand for further parsing.
- parser = commandline.ArgumentParser(caching=True, default_log_level='notice',
- add_help=cmd_name is not None)
+ parser = commandline.ArgumentParser(caching=True, default_log_level='notice')
subparsers = parser.add_subparsers(title='Subcommands', dest='subcommand')
subparsers.required = True