Skip to content

Subcommands¤

Subcommands may be implemented with seali.group. (This is actually just a seali.command whose implementation checks the first positional argument, and then redispatches to another command. It's just a convenient helper, not anything special.)

seali.group(*, default: None | seali.Command = None, name: None | str = None, help: None | seali.Help = None, version: None | str = None, subcommands: Sequence[seali.Command]) -> seali.Command ¤

Group multiple commands, to provide subcommands.

Arguments:

  • default: a command to run if no subcommand is provided. Mutually exclusive with name, help and version.
  • name: name. Either this or default must be provided.
  • help: help message, as seali.command. Mutually exclusive with default.
  • version: version, as seali.command. Mutually exclusive with default.
  • subcommands: a list/tuple of subcommands.

Returns:

As seali.command.

Command line inputs:

The first positional input is inspected, and its value used to redispatch to the appropriate element of subcommands. All flags, options, and remaining positional inputs are passed on to the subcommand.

If no positional inputs are present...
...and default is available, then it will be called with any options and flags.
...and no default is available, then an error will be raised.

Example

import seali

@seali.command
def bar(...): ...

@seali.command
def baz(...): ...

foo = seali.group(name="foo", subcommands=[bar, baz])

if __name__ == "__main__":
   foo()