scriptine.command – run scripts with commands

Module Contents

scriptine.command.run(namespace=None, args=None, command_suffix='_command', add_dry_run_option=True, add_verbosity_option=True)

Parse and run commands.

Will search namespace for functions that end with command_suffix.

Parameters:
  • namespace – the namespace/module to search for commands
  • args – the arguments for the command parser. defaults to sys.argv
  • command_suffix – function name suffix that indicates that a function is a command.

Command decorators

These decorators set options on command functions.

scriptine.command.no_help()

Disable the --help option for this command.

scriptine.command.no_verbosity()

Disable the --verbose and --quite options for this command.

scriptine.command.non_strict()

Disable strict argument parsing. Does not report an error when the command is called with unknown options.

scriptine.command.fetch_all(arg_name)

Pass all arguments that the parser did not matche to an options or argument to this named arg_name.

Use this decorator when you are interessted in all arguments:

@fetch_all('args')
def foo_command(required_arg, the_rest):
    print '|'.join(the_rest)

The result when calling this command:

% example.py foo arg1 arg2 arg3
arg2|arg3

If you are interessted in aditional options (e.g. --bar) use fetch_all() together with the non_strict() decorator.

Table Of Contents

Previous topic

scriptine

Next topic

scriptine.log – simple logging for commands

This Page