Decorator to mark function to be used as command for CLI.
Usage:
from opster import command, dispatch
@command()
def run(argument,
optionalargument=None,
option=('o', 'default', 'help for option'),
no_short_name=('', False, 'help for this option')):
print argument, optionalargument, option, no_short_name
if __name__ == '__main__':
run.command()
# or, if you want to have multiple subcommands:
if __name__ == '__main__':
dispatch()
If defined, options should be a list of 4-tuples in format:
(shortname, longname, default, help)
Where:
- shortname is a single letter which can be used then as an option specifier on command line (like -a). Will be not used if contains falsy value (empty string, for example)
- longname - main identificator of an option, can be used as on a command line with double dashes (like --longname)
- default value for an option, type of it determines how option will be processed
- help string displayed as a help for an option when asked to
Dispatch command line arguments using subcommands.
Central object for command dispatching system.
Decorator to mark function to be used as command for CLI.
Usage:
from opster import command, dispatch
@command()
def run(argument,
optionalargument=None,
option=('o', 'default', 'help for option'),
no_short_name=('', False, 'help for this option')):
print argument, optionalargument, option, no_short_name
if __name__ == '__main__':
run.command()
# or, if you want to have multiple subcommands:
if __name__ == '__main__':
dispatch()
If defined, options should be a list of 4-tuples in format:
(shortname, longname, default, help)
Where:
- shortname is a single letter which can be used then as an option specifier on command line (like -a). Will be not used if contains falsy value (empty string, for example)
- longname - main identificator of an option, can be used as on a command line with double dashes (like --longname)
- default value for an option, type of it determines how option will be processed
- help string displayed as a help for an option when asked to
Dispatch command line arguments using subcommands.