Commit fa9ef46b authored by Mike Frysinger's avatar Mike Frysinger Committed by Commit Bot

grit: add support for standard --help flag

Trying to use --help with grit just ends in errors like:
  $ grit --help
  getopt.GetoptError: option --help not recognized

Add support for it with `grit --help`.  This doesn't update the
subtools for now as that'll take much more work/thought.

We also don't support the -h short option as it's already used for
other things, and we don't want to complicate/break it.

Bug: 747171
Change-Id: Ied24f810ed583d464dc2970c8e472784e22ec044
Reviewed-on: https://chromium-review.googlesource.com/c/1327421Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608196}
parent 090ba542
...@@ -155,7 +155,7 @@ class Options(object): ...@@ -155,7 +155,7 @@ class Options(object):
def ReadOptions(self, args): def ReadOptions(self, args):
"""Reads options from the start of args and returns the remainder.""" """Reads options from the start of args and returns the remainder."""
(opts, args) = getopt.getopt(args, 'vxi:p:h:') (opts, args) = getopt.getopt(args, 'vxi:p:h:', ('help',))
for (key, val) in opts: for (key, val) in opts:
if key == '-h': self.hash = val if key == '-h': self.hash = val
elif key == '-i': self.input = val elif key == '-i': self.input = val
...@@ -168,6 +168,9 @@ class Options(object): ...@@ -168,6 +168,9 @@ class Options(object):
self.extra_verbose = True self.extra_verbose = True
util.extra_verbose = True util.extra_verbose = True
elif key == '-p': self.profile_dest = val elif key == '-p': self.profile_dest = val
elif key == '--help':
PrintUsage()
sys.exit(0)
if not self.input: if not self.input:
if 'GRIT_INPUT' in os.environ: if 'GRIT_INPUT' in os.environ:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment