def __call__(self, parser, namespace, values, option_string=None): """Render a help document according to the style in values. Args: parser: The ArgParse object. namespace: The ArgParse namespace. values: The --document flag ArgDict() value: style=STYLE The output style. Must be specified. title=DOCUMENT TITLE The document title. notes=SENTENCES Inserts SENTENCES into the document NOTES section. option_string: The ArgParse flag string. Raises: parser_errors.ArgumentError: For unknown flag value attribute name. """ base.LogCommand(parser.prog, namespace) if default_style: # --help metrics.Loaded() style = default_style notes = None title = None for attributes in values: for name, value in six.iteritems(attributes): if name == 'notes': notes = value elif name == 'style': style = value elif name == 'title': title = value else: raise parser_errors.ArgumentError( 'Unknown document attribute [{0}]'.format(name)) if title is None: title = command.dotted_name metrics.Help(command.dotted_name, style) # '--help' is set by the --help flag, the others by gcloud <style> ... . if style in ('--help', 'help', 'topic'): style = 'text' md = io.StringIO(markdown.Markdown(command)) out = (io.StringIO() if console_io.IsInteractive(output=True) else None) if style == 'linter': meta_data = GetCommandMetaData(command) else: meta_data = None render_document.RenderDocument(style, md, out=out or log.out, notes=notes, title=title, command_metadata=meta_data) metrics.Ran() if out: console_io.More(out.getvalue()) sys.exit(0)
def __call__(self, parser, namespace, values, option_string=None): """Render a help document according to the style in values. Args: parser: The ArgParse object. namespace: The ArgParse namespace. values: The --document flag ArgDict() value: style=STYLE The output style. Must be specified. title=DOCUMENT TITLE The document title. notes=SENTENCES Inserts SENTENCES into the document NOTES section. option_string: The ArgParse flag string. Raises: ArgumentTypeError: For unknown flag value attribute name. """ if default_style: # --help metrics.Loaded() style = default_style notes = None title = None for attributes in values: for name, value in attributes.iteritems(): if name == 'notes': notes = value elif name == 'style': style = value elif name == 'title': title = value else: raise argparse.ArgumentTypeError( 'Unknown document attribute [{}]'.format(name)) if title is None: title = command.dotted_name metrics.Help(command.dotted_name, style) # 'help' is set by the help command, '--help' by the --help flag. if style in ('--help', 'help'): style = 'text' md = cStringIO.StringIO(markdown.Markdown(command)) out = (cStringIO.StringIO() if console_io.IsInteractive( output=True) else None) render_document.RenderDocument(style, md, out=out, notes=notes, title=title) metrics.Ran() if out: console_io.More(out.getvalue()) sys.exit(0)
def Func(): metrics.Help(command.dotted_name, '-h') log.out.write(command.GetUsage())
def Func(): metrics.Help(command.dotted_name, '-h') print usage_text.ShortHelpText(command, command.ai)
def Func(): metrics.Help(command.dotted_name, '--help') help_func( command.GetPath(), default=usage_text.ShortHelpText(command, command.ai))