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)
  addCommand(self, name, func, arguments, argoptions, helptext)
Registers a command.
  addSession(self, newsession, basesession)
Tells the manager to create a new session based on another session. (inherited from Manager)
  clear(self, ses)
Removes everything the manager was managing--essentially reinitializes it. (inherited from Manager)
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.
string getInfo(self, ses, text)
Returns information managed by this class. (inherited from Manager)
list of strings getState(self, ses)
Returns the state of something as a list of command strings without the command char (which is added by #write). (inherited from Manager)
string getStatus(self, ses)
Returns a one-liner status of the state of this manager for a given session. (inherited from Manager)
boolean removeCommand(self, name)
Removes a command (and the help text) for whatever reasons.
  removeSession(self, ses)
Tells the manager to remove information regarding the session. (inherited from Manager)

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 1.1 on Mon Apr 28 21:11:24 2003 http://epydoc.sf.net