Command Sets are the extension point for
T Wiki Shell Contrib. Without them, it's only an empty shell (no pun intended)
Creation
Command Sets are perl modules that define one or more of the following subs:
| Sub | Description |
| run | Command execution |
| smry | One-line help to be used by "help" to sumarize all the commands |
| help | Complete help to be shown by the "help " command |
| run_ | Sub Command? execution |
| smry_ | One-line help to be used by "help" to sumarize all the commands |
| help_ | Complete help to be shown by the "help " command |
There are several ways to implement
Command Set. The first thing to understand is how the commands map to perl modules and handler subs. See the following table:
| command/subcommand | Module Name | Implemented Handlers |
| dump | Dump | run, smry, help |
| dump config | Dump | run_config, smry_config, help_config |
| Dump::Config | run, smry, help |
| dump handlers | Dump | run_handlers, smry_handlers, help_handlers |
| Dump::Handlers | run, smry, help |
The
Command Set can be on any TWiki subpackage and can be imported using the
import command. The special case are
Command Set under the TWiki::Contrib::CommandSet package (anywhere in @INC) which are "discovered" and imported at startup.
Check the bundled
Command Sets for examples on how to implement them.
Any
Command Set that needs an special initialization when imported can use the following hook:
onImport($shell,$config)
Called when the
Command Set is being imported.
Loading a Command Set to the Shell
To load a
Command Set, use:
import <command>
or
import <CommandSet_module_without_prefix>
if it's a core
Command Set, or
import <CommandSet_module>
if not.
Also, if the
Command Set is in the package TWiki::Contrib::CommandSet it will be imported automatically on it first invocation (for example, the Dump
Command Set will be loaded automatically when the dump, dump config or dump handlers commands are called).
All the handlers (run, help and smry) will be called with the following parameters (in order):
| Parameter | Description |
| $shell | A reference to the shell object |
| $config | A reference to the config object |
| @args | The list of parameters passed to the command |