Squirrel command line tool main program.


run([args, command, subcommands, description])

Setup and run Squirrel-based application.

run(args=None, command=None, subcommands=[], description='\nPyrocko Squirrel based script.\n\nRun with --help to get further help.', **kwargs)[source]

Setup and run Squirrel-based application.

The implementation of the tool can be provided by one or multiple SquirrelCommand instances. This driver function sets up a SquirrelArgumentParser, and processes command line arguments, and dispatches execution to the selected command or subcommand. The program is set up to provide and automatically handle --help, --loglevel, and --progress. If an exception of type pyrocko.squirrel.error.SquirrelError or pyrocko.squirrel.error.ToolError is caught, the error is logged and the program is terminated with exit code 1.

  • args (list of str) – Arguments passed to parse_args(). By default uses py:attr:sys.argv.

  • command (SquirrelCommand or module) – Implementation of the command. It must provide setup(parser) and run(parser, args).

  • subcommands (list of SquirrelCommand instances or modules) – Configures the program to offer multiple subcommands. The command to execute is selected with the first argument passed to args. Implementations must provide make_subparser(subparsers), setup(parser), and run(parser, args).

  • description (str) – Description of the program.