class documentation

class Command(object): (source)

Known subclasses: zim.main.command.GtkCommand, zim.main.HelpCommand, zim.main.NotebookCommand, zim.main.VersionCommand

View In Hierarchy

Base class for commandline commands, used by zim to abstract part of the main() functionality and allow better testability of commandline arguments.

Sub-classes can define the options and arguments that they require. Then only the run() method needs to be defined to implement the actual command. In the run() method self.opts and self.args can be accessed to get the commandline options (dict) and the commandline arguments (list) respectively.

Method __init__ Constructor @param command: the command switch (first commandline argument) @param pwd: optional working directory path
Method get_arguments Get the arguments, to be used by the implementation of run() @raises UsageError: when arguments are not correct @returns: tuple of arguments, padded with None to correct length
Method get_options Retrieve a dict with a sub-set of the command options @param names: that options in the subset
Method ignore_options Undocumented
Method parse_options No summary
Method run Run the command @raises UsageError: when arguments are not correct @implementation: must be implemented by subclasses
Class Variable arguments Undocumented
Class Variable default_options Undocumented
Class Variable options Undocumented
Instance Variable args Undocumented
Instance Variable command Undocumented
Instance Variable opts Undocumented
Instance Variable pwd Undocumented
def __init__(self, command, pwd=None): (source)
Constructor
Parameters
commandthe command switch (first commandline argument)
pwdoptional working directory path
def get_arguments(self): (source)
Get the arguments, to be used by the implementation of run()
Returns
tuple of arguments, padded with None to correct length
Raises
UsageErrorwhen arguments are not correct
def get_options(self, *names): (source)
Retrieve a dict with a sub-set of the command options
Parameters
*namesthat options in the subset
def ignore_options(self, *options): (source)

Undocumented

def parse_options(self, *args): (source)
Parse commandline options for this command Sets the attributes 'args' and 'opts' to a list of arguments and a dictionary of options respectively
Parameters
*argsall remaining options to be parsed
Raises
GetOptErrorwhen options are not correct
def run(self): (source)
default_options: tuple = (source)

Undocumented

Undocumented

command = (source)

Undocumented

Undocumented

Undocumented