Created
August 16, 2011 09:03
-
-
Save siwells/1148699 to your computer and use it in GitHub Desktop.
A simple example of using cmd to build a simple REPL within a python CLI tool.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cmd | |
class CmdProcessor(cmd.Cmd): | |
"""A Simple Command Processor.""" | |
def do_greeting(self, line): | |
print "Hello World!" | |
def do_EOF(self, line): | |
return True | |
def do_quit(self, line): | |
return True | |
if __name__ == '__main__': | |
CmdProcessor().cmdloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment