ocarina/src/core/cli.py

50 lines
1.0 KiB
Python

# This is a simple test plugin, to make sure everything is working
__author__="bjschuma"
__date__ ="$Jan 20, 2010 7:37:39 PM$"
from bt import plugin
#from bt.needle import Needle
from bt.signal import *
from bt.message import *
import cline.loop
import cline.addch
import cline.message
#import settings
class Plugin(plugin.Plugin):
def __init__(self):
plugin.Plugin.__init__(self)
self.help = "The command line interface"
self.usage = "cli [prompt]"
def open(self):
write("Starting CLI", True)
# Register our run function and close function
register("run", cline.loop.loop)
register("quit", cline.loop.quit)
# Initialize a dictionary for key press inputs
settings.set("keyinput", dict())
settings.get("keyinput")[127] = cline.addch.backspace
settings.get("keyinput")[10] = cline.addch.enter
def close(self):
cline.loop.quit()
write("CLI has been stopped", True)
settings.delete("keyinput")
def run(self,args):
if args==None or len(args)<2:
write(self.usage)
if args[0]=="prompt":
settings.set("prompt",args[1]+" ")