tools/site_compare/command_line.py
def DoHelpCommand(command):
  """Executed when the command is 'help'."""
  out = command.cmdline.out
  width = command['--width']

  if 'command' not in command:
    out.write(command.GetUsageString())
    out.write("\n\n")

    indent = 5
    gutter = 2

    command_width = (
      max([len(cmd.names[0]) for cmd in command.cmdline.commands]) + gutter)

    for cmd in command.cmdline.commands:
      cmd_name = cmd.names[0]

      initial_indent = (" "*indent + cmd_name + " "*
                        (command_width+gutter-len(cmd_name)))
      subsequent_indent = " "*(indent+command_width+gutter)

      out.write(textwrap.fill(cmd.helptext, width,
                              initial_indent=initial_indent,
                              subsequent_indent=subsequent_indent))
      out.write("\n")

    out.write("\n")

  else:
    help_cmd = command.cmdline[command['command']]

    out.write(textwrap.fill(help_cmd.helptext, width))
    out.write("\n\n")
    out.write(help_cmd.GetUsageString(width=width))
    out.write("\n\n")
    out.write(help_cmd.GetHelpString(width=width))
    out.write("\n")

    command.cmdline.Exit()
Executed when the command is 'help'.
Executed when the command is 'help'.
Executed when the command is ' help ' .
def DoHelpCommand(command):
  out = command.cmdline.out
  width = command['--width']
  if 'command' not in command:
    out.write(command.GetUsageString())
    out.write("\n\n")
    indent = 5
    gutter = 2
    command_width = (
      max([len(cmd.names[0]) for cmd in command.cmdline.commands]) + gutter)
    for cmd in command.cmdline.commands:
      cmd_name = cmd.names[0]
      initial_indent = (" "*indent + cmd_name + " "*
                        (command_width+gutter-len(cmd_name)))
      subsequent_indent = " "*(indent+command_width+gutter)
      out.write(textwrap.fill(cmd.helptext, width,
                              initial_indent=initial_indent,
                              subsequent_indent=subsequent_indent))
      out.write("\n")
    out.write("\n")
  else:
    help_cmd = command.cmdline[command['command']]
    out.write(textwrap.fill(help_cmd.helptext, width))
    out.write("\n\n")
    out.write(help_cmd.GetUsageString(width=width))
    out.write("\n\n")
    out.write(help_cmd.GetHelpString(width=width))
    out.write("\n")
    command.cmdline.Exit()
def DoHelpCommand ( command ) : out = command . cmdline . out width = command [ '--width' ] if 'command' not in command : out . write ( command . GetUsageString ( ) ) out . write ( "\n\n" ) indent = 5 gutter = 2 command_width = ( max ( [ len ( cmd . names [ 0 ] ) for cmd in command . cmdline . commands ] ) + gutter ) for cmd in command . cmdline . commands : cmd_name = cmd . names [ 0 ] initial_indent = ( " " * indent + cmd_name + " " * ( command_width + gutter - len ( cmd_name ) ) ) subsequent_indent = " " * ( indent + command_width + gutter ) out . write ( textwrap . fill ( cmd . helptext , width , initial_indent = initial_indent , subsequent_indent = subsequent_indent ) ) out . write ( "\n" ) out . write ( "\n" ) else : help_cmd = command . cmdline [ command [ 'command' ] ] out . write ( textwrap . fill ( help_cmd . helptext , width ) ) out . write ( "\n\n" ) out . write ( help_cmd . GetUsageString ( width = width ) ) out . write ( "\n\n" ) out . write ( help_cmd . GetHelpString ( width = width ) ) out . write ( "\n" ) command . cmdline . Exit ( )
Executed when the command is 'help'.
Executed when the command is ' help ' .
"""Executed when the command is 'help'."""
command