addCommand method

ArgParser addCommand (String name, [ ArgParser parser ])

Defines a command.

A command is a named argument which may in turn define its own options and subcommands using the given parser. If parser is omitted, implicitly creates a new one. Returns the parser for the command.


ArgParser addCommand(String name, [ArgParser parser]) {
  // Make sure the name isn't in use.
  if (_commands.containsKey(name)) {
    throw ArgumentError('Duplicate command "$name".');

  if (parser == null) parser = ArgParser();
  _commands[name] = parser;
  return parser;