Invoke and use an arbitrary IExecutable object
This class is designed to allow specification of an arbitrary
name or URL on the command line to retrieve and invoke the
designated object.
If the name is not a scheme-prefixed URL, it is first converted to
a name in the peak.running.shortcuts configuration property namespace,
thus allowing simpler names to be used. For example, runIni is a
shortcut for "import:peak.running.commands:IniInterpreter" . If you
use a sitewide PEAK_CONFIG file, you can add your own shortcuts to
the peak.running.shortcuts namespace. (See the peak.ini file for
current shortcuts, and examples of how to define them.)
The object designated by the name or URL in 'argv[1]' must be an
'IExecutable'; that is to say it must implement one of the IExecutable
sub-interfaces, or else be callable without arguments. (See the
running.IExecutable interface for more details.)
Here's an example bootstrap script (which is installed as the peak
script by the PEAK distribution on posix operating systems):
#!/usr/bin/env python2.2
from peak.running import commands
commands.runMain( commands.Bootstrap )
The script above will look up its first supplied command line argument,
and then invoke the found object as a command, supplying the remaining
command line arguments.
Methods
|
|
cmdParent
getCommandParent
interpret
showHelp
|
|
cmdParent
|
cmdParent ( self )
|
|
getCommandParent
|
getCommandParent ( self )
Get or create a component to be used as the subcommand's parent
|
|
interpret
|
interpret ( self, name )
Exceptions
|
|
InvocationError( "Invalid command object", factory, "found at", name )
|
|
|
showHelp
|
showHelp ( self )
Display usage message on stderr
|
|