Package lyntin :: Module commandmanager :: Class CommandManager
[show private | hide private]
[frames | no frames]

Class CommandManager

Manager --+
          |
         CommandManager


The CommandManager holds a series of _CommandData objects and methods to manipulate and use them. Lyntin developers can add their own commands to Lyntin.

There should be one instance of the CommandManager and the engine should have it. All CommandManager interaction should be done through the exported module.
Method Summary
  __init__(self, e)
  addCommand(self, name, func, arguments, argoptions, helptext)
Registers a command.
None or string filter(self, args)
Takes in user command lines and handles commands that start with a Lyntin command character.
ArgParser instance getArgParser(self, name)
Returns the arguments parser for a given command name.
function getCommand(self, name)
Returns the function for a given command name.
list of strings getCommands(self)
Returns a list of the commands we have registered.
boolean removeCommand(self, name)
Removes a command (and the help text) for whatever reasons.
    Inherited from Manager
  addSession(self, newsession, basesession)
Tells the manager to create a new session based on another session.
  clear(self, ses)
Removes everything the manager was managing--essentially reinitializes it.
string getInfo(self, ses, text)
Returns information managed by this class.
list of mappings getInfoMappings(self, item, ses)
Returns a list of maps of parameter name -> value that represents all the info this manager is managing for this session.
list of strings getItems(self)
Returns a list of the items that this manager manages.
list of tuples getParameters(self, item)
Returns a list of tuples of the parameters we're storing in this manager and the description of each parameter.
string getStatus(self, ses)
Returns a one-liner status of the state of this manager for a given session.
  removeSession(self, ses)
Tells the manager to remove information regarding the session.

Method Details

addCommand(self, name, func, arguments=None, argoptions=None, helptext='')

Registers a command.
Parameters:
name - the name of the command to add
           (type=string)
func - the function that handles the command
           (type=function)
arguments - the argument spec to create the argparser
           (type=string)
argoptions - options for how the argument spec should be parsed
           (type=string)
helptext - the help text for this command for the user
           (type=string)
Raises:
ValueError - if the function is uncallable
Exception - if the argument spec for the command is unparseable

filter(self, args)

Takes in user command lines and handles commands that start with a Lyntin command character.
Parameters:
args - (session, internal boolean, ..., current input text)
           (type=tuple)
Returns:
None if we handled the input, or the current input text if we didn't
           (type=None or string)

getArgParser(self, name)

Returns the arguments parser for a given command name.
Parameters:
name - the name of the command whose arguments should be retrieved
           (type=string)
Returns:
argument parsing object to convert incoming arguments into a dictionary to pass to the command function
           (type=ArgParser instance)

getCommand(self, name)

Returns the function for a given command name.
Parameters:
name - the name of the command to retrieve
           (type=string)
Returns:
the function in question or None
           (type=function)

getCommands(self)

Returns a list of the commands we have registered.
Returns:
all the commands that have been registered
           (type=list of strings)

removeCommand(self, name)

Removes a command (and the help text) for whatever reasons.
Parameters:
name - the name of the command to remove
           (type=string)
Returns:
0 if no command was found, 1 if the command was removed succesfully.
           (type=boolean)

Generated by Epydoc 2.1 on Mon Aug 9 09:17:42 2004 http://epydoc.sf.net