Example #1
0
def create_parser():
    '''
  Main parser
  :return:
  '''
    parser = hrc_parse.HeronArgumentParser(
        prog='heron',
        epilog=HELP_EPILOG,
        formatter_class=config.SubcommandHelpFormatter,
        add_help=False,
        fromfile_prefix_chars='@')

    subparsers = parser.add_subparsers(title="Available commands",
                                       metavar='<command> <options>')

    activate.create_parser(subparsers)
    deactivate.create_parser(subparsers)
    cli_help.create_parser(subparsers)
    kill.create_parser(subparsers)
    restart.create_parser(subparsers)
    submit.create_parser(subparsers)
    update.create_parser(subparsers)
    version.create_parser(subparsers)

    return parser
Example #2
0
def create_parser():
  '''
  Main parser
  :return:
  '''
  parser = hrc_parse.HeronArgumentParser(
      prog='heron',
      epilog=HELP_EPILOG,
      formatter_class=config.SubcommandHelpFormatter,
      add_help=False,
      fromfile_prefix_chars='@')

  subparsers = parser.add_subparsers(
      title="Available commands",
      metavar='<command> <options>')

  activate.create_parser(subparsers)
  deactivate.create_parser(subparsers)
  cli_help.create_parser(subparsers)
  kill.create_parser(subparsers)
  restart.create_parser(subparsers)
  submit.create_parser(subparsers)
  update.create_parser(subparsers)
  version.create_parser(subparsers)

  return parser
Example #3
0
  def test_parser_commandline_positional_withrc(self):
    sys.argv = []

    parser = hr_argparser.HeronArgumentParser(
        prog='heron',
        epilog=help_epilog,
        formatter_class=config.SubcommandHelpFormatter,
        fromfile_prefix_chars='@',
        add_help=False,
        rcfile=self.testrcfile,
        rccommand="submit",
        rcclusterrole="local")

    subparsers = parser.add_subparsers(
        title="Available commands",
        metavar='<command> <options>')
    submit.create_parser(subparsers)
    args, _ = parser.parse_known_args(["submit", "local", "~/.heron/examples/heron-examples.jar",
                                       "com.twitter.heron.examples.ExclamationTopology",
                                       "ExclamationTopology"])
    namespace = vars(args)
    self.assertEqual('True', namespace['verbose'])
    hr_argparser.HeronArgumentParser.clear()
Example #4
0
  def test_parser_commandline_norc(self):
    sys.argv = []

    parser = argparser.ArgumentParser(
        prog='heron',
        epilog=help_epilog,
        formatter_class=config.SubcommandHelpFormatter,
        fromfile_prefix_chars='@',
        add_help=False)

    subparsers = parser.add_subparsers(
        title="Available commands",
        metavar='<command> <options>')
    submit.create_parser(subparsers)
    args, _ = parser.parse_known_args(["submit", "local", "~/.heron/examples/heron-examples.jar",
                                       "com.twitter.heron.examples.ExclamationTopology",
                                       "ExclamationTopology"])

    namespace = vars(args)
    self.assertEqual('submit', namespace['subcommand'])
    self.assertEqual('local', namespace['cluster/[role]/[env]'])
    self.assertEqual('~/.heron/examples/heron-examples.jar', namespace['topology-file-name'])
    self.assertEqual('com.twitter.heron.examples.ExclamationTopology', namespace['topology-class-name'])
Example #5
0
  def test_parser_commandline_positional_error(self):
    sys.argv = []

    parser = hr_argparser.HeronArgumentParser(
        prog='heron',
        epilog=help_epilog,
        formatter_class=config.SubcommandHelpFormatter,
        fromfile_prefix_chars='@',
        add_help=False,
        rcfile=self.testrcfile,
        rccommand="submit",
        rcclusterrole="ilocal")

    subparsers = parser.add_subparsers(
        title="Available commands",
        metavar='<command> <options>')
    submit.create_parser(subparsers)
    try:
      _, _ = parser.parse_known_args(["submit", "ilocal"])
    except ValueError:
      pass
    else:
      self.fail('ValueError expected for test_parser_commandline_positional_error')
    hr_argparser.HeronArgumentParser.clear()