This commit is contained in:
Burt Bielicki 2016-03-15 12:57:11 -07:00
Родитель 96dc26ae6c
Коммит 76092a4a28
3 изменённых файлов: 23 добавлений и 7 удалений

Просмотреть файл

@ -14,7 +14,7 @@
<LaunchProvider>Standard Python launcher</LaunchProvider>
<InterpreterId>{12627503-1b89-4332-94a5-8ddd298e66ac}</InterpreterId>
<InterpreterVersion>3.5</InterpreterVersion>
<CommandLineArguments>login --help</CommandLineArguments>
<CommandLineArguments>account li</CommandLineArguments>
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />

Просмотреть файл

@ -177,7 +177,10 @@ class ArgumentParser(object):
nouns.append(n.lower())
except LookupError:
if '$args' not in m:
show_usage = True
#show_usage = True
print(L('\nCommand "{0}" not found, names starting with "{0}":\n'.format(n)))
args.append('--complete')
show_completions = True
break
n = next(it, '')
@ -228,8 +231,8 @@ class ArgumentParser(object):
try:
parsed[a]
except KeyError:
print(L("Missing required argument {}".format(a)))
return ArgumentParserResult(self._display_usage(nouns, m, out))
print(L('Missing required argument "{}"'.format(a)))
return ArgumentParserResult("")
try:
output_format = others.pop('output') if others else None

Просмотреть файл

@ -9,21 +9,31 @@ from ._output import OutputProducer, TableOutput, format_table, format_list, for
def print_detailed_help(help_file, out=sys.stdout): # TODO: wire up out to print statements
indent = 0
print('')
_printIndent('{0}{1}'.format(help_file.command, ': ' + help_file.short_summary if help_file.short_summary else ''), indent)
_printIndent('{0}{1}'.format(help_file.command, ': ' + help_file.short_summary
if help_file.short_summary
else ''),
indent)
indent = 1
_printIndent('{0}'.format(help_file.long_summary), indent)
print('')
indent = 0
_printIndent('Arguments' if help_file.type == 'command' else 'Sub-Commands', indent)
_printIndent('Arguments'
if help_file.type == 'command'
else 'Sub-Commands', indent)
if help_file.type == 'command':
if len(help_file.parameters) == 0:
_printIndent('none', indent)
max_name_length = max(len(p.name) for p in help_file.parameters)
for p in help_file.parameters:
indent = 1
_printIndent('{0}{1}'.format(p.name, ': ' + p.short_summary if p.short_summary else ''), indent)
_printIndent('{0}{1}{2}{3}'.format(p.name,
' [Required]' if p.required else '',
get_column_indent(p.name, max_name_length),
': ' + p.short_summary if p.short_summary else ''),
indent)
indent = 2
_printIndent('{0}'.format(p.long_summary), indent)
@ -140,6 +150,9 @@ def _printIndent(str, indent=0):
tw = textwrap.TextWrapper(initial_indent = " "*indent, subsequent_indent = " "*indent)
print(tw.fill(str))
def get_column_indent(text, max_name_length):
return ' '*(max_name_length - len(text))
def _load_help_file(delimiters):
s = """
type: command