Package common :: Module clcommands
[frames] | no frames]

Module clcommands

source code

Helper functions to support command line tools providing more than
one command.

e.g called as "tool command [options] args..." where <options> and <args> are
command'specific

Classes
  BadCommandUsage
Raised when an unknown command is used or when a command is not correctly used (bad options, too much / missing arguments...).
  CommandError
Raised when a command can't be processed and we want to display it and exit, without traceback nor usage displayed.
  CommandLine
Usage:
  Command
Base class for command line commands.
  ListCommandsCommand
list available commands, useful for bash completion.
Functions
 
register_commands(commands)
register existing commands
source code
 
main_run(args, doc=None, copyright=None, version=None)
command line tool: run command specified by argument list (without the program name).
source code
 
pop_arg(args_list, expected_size_after=None, msg="Missing argument")
helper function to get and check command line arguments
source code
Variables
  DEFAULT_COPYRIGHT = '...
Function Details

register_commands(commands)

source code 
register existing commands

Decorators:
  • @deprecated('use cls.register(cli)')

main_run(args, doc=None, copyright=None, version=None)

source code 
command line tool: run command specified by argument list (without the
program name). Raise SystemExit with status 0 if everything went fine.

>>> main_run(sys.argv[1:])

Decorators:
  • @deprecated('use args.pop(0)')

pop_arg(args_list, expected_size_after=None, msg="Missing argument")

source code 
helper function to get and check command line arguments

Decorators:
  • @deprecated('use args.pop(0)')

Variables Details

DEFAULT_COPYRIGHT

Value:
'''\
Copyright (c) 2004-2011 LOGILAB S.A. (Paris, FRANCE), all rights reser\
ved.
http://www.logilab.fr/ -- mailto:contact@logilab.fr'''