Commit 2440c5a9 authored by Mike Frysinger's avatar Mike Frysinger Committed by Commit Bot

grit: delay "help" builtin parsing

The "help" ad-hoc parsing only works in the simplest case:
  grit help
  grit help foo

When passing options to grit, the "help" builtin fails and producing
confusing output:
  $ grit -i ... help
  No such tool.  Try running 'grit help' for a list of tools.
  $ grit -i ... help xmb
  No such tool.  Try running 'grit help' for a list of tools.

Delay parsing of the "help" tool until after we've processed grit's
core options.

Bug: 747171
Change-Id: Iae5fdee2493346cee4272368ac8862647433faaf
Reviewed-on: https://chromium-review.googlesource.com/c/1320690Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605854}
parent a6966377
......@@ -196,20 +196,6 @@ def Main(args):
"""Parses arguments and does the appropriate thing."""
util.ChangeStdoutEncoding()
if not args or (len(args) == 1 and args[0] == 'help'):
PrintUsage()
return 0
elif len(args) == 2 and args[0] == 'help':
tool = args[1].lower()
if not _GetToolInfo(tool):
print "No such tool. Try running 'grit help' for a list of tools."
return 2
print ("Help for 'grit %s' (for general help, run 'grit help'):\n"
% (tool))
print _GetToolInfo(tool)[_FACTORY]().__doc__
return 0
else:
options = Options()
try:
args = options.ReadOptions(args) # args may be shorter after this
......@@ -220,7 +206,22 @@ def Main(args):
if not args:
print "No tool provided. Try running 'grit help' for a list of tools."
return 2
tool = args[0]
if tool == 'help':
if len(args) == 1:
PrintUsage()
return 0
else:
tool = args[1]
if not _GetToolInfo(tool):
print "No such tool. Try running 'grit help' for a list of tools."
return 2
print ("Help for 'grit %s' (for general help, run 'grit help'):\n"
% (tool))
print _GetToolInfo(tool)[_FACTORY]().__doc__
return 0
if not _GetToolInfo(tool):
print "No such tool. Try running 'grit help' for a list of tools."
return 2
......
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