class Command(object): (source)
Known subclasses: zim.main.command.GtkCommand
, zim.main.HelpCommand
, zim.main.NotebookCommand
, zim.main.VersionCommand
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 |
Parameters | |
command | the command switch (first commandline argument) |
pwd | optional working directory path |
Returns | |
tuple of arguments, padded with None to correct length | |
Raises | |
UsageError | when arguments are not correct |
Parameters | |
*args | all remaining options to be parsed |
Raises | |
GetOptError | when options are not correct |
zim.main.ExportCommand
, zim.main.GuiCommand
, zim.main.GuiCommand
, zim.main.HelpCommand
, zim.main.IndexCommand
, zim.main.SearchCommand
, zim.main.ServerCommand
, zim.main.ServerGuiCommand
, zim.main.ServerGuiCommand
, zim.main.VersionCommand
Raises | |
UsageError | when arguments are not correct |
Unknown Field: implementation | |
must be implemented by subclasses |
zim.main.ExportCommand
, zim.main.GuiCommand
, zim.main.GuiCommand
, zim.main.IndexCommand
, zim.main.ServerCommand
, zim.main.ServerGuiCommand
, zim.main.ServerGuiCommand
Undocumented