Package flumotion :: Package extern :: Package command :: Module command :: Class Command
[hide private]

Class Command

source code

Known Subclasses:

I am a class that handles a command for a program. Commands can be nested underneath a command for further processing.

Instance Methods [hide private]
 
__init__(self, parentCommand=None, stdout=sys.stdout, stderr=sys.stdout)
Create a new command instance, with the given parent.
source code
 
addOptions(self)
Override me to add options to the parser.
source code
 
do(self, args)
Override me to implement the functionality of the command.
source code
int
parse(self, argv)
Parse the given arguments and act on them.
source code
 
handleOptions(self, options)
Handle the parsed options.
source code
 
outputHelp(self)
Output help information.
source code
 
outputUsage(self)
Output usage information.
source code
 
getRootCommand(self)
Return the top-level command, which is typically the program.
source code
 
debug(self, format, *args)
Override me to handle debug output from this class.
source code
Class Variables [hide private]
  name = None
name of the command, lowercase
list of str aliases = None
list of alternative lowercase names recognized
  usage = None
short one-line usage string; %command gets expanded to a sub-command or [commands] as appropriate
  summary = None
short one-line summary of the command
  description = None
longer paragraph explaining the command
  parentCommand = None
dict of str -> Command subCommands = None
dict of name -> commands below this command
  subCommandClasses = None
  aliasedSubCommands = None
OptionParser parser = None
the option parser used for parsing
Method Details [hide private]

__init__(self, parentCommand=None, stdout=sys.stdout, stderr=sys.stdout)
(Constructor)

source code 

Create a new command instance, with the given parent. Allows for redirecting stdout and stderr if needed. This redirection will be passed on to child commands.

parse(self, argv)

source code 

Parse the given arguments and act on them.

Parameters:
  • argv (list of str) - list of arguments to parse
Returns: int
an exit code

outputUsage(self)

source code 

Output usage information. Used when the options or arguments were missing or wrong.