Skip to content

Instantly share code, notes, and snippets.

@pbassut
Created November 5, 2014 22:31
Show Gist options
  • Save pbassut/ce36e4f3008ab8e90814 to your computer and use it in GitHub Desktop.
Save pbassut/ce36e4f3008ab8e90814 to your computer and use it in GitHub Desktop.
from cmd import Cmd
class MyCmd(Cmd):
def onecmd(self, str):
if str == 'ls':
# here we should print the files in the cwd
print 'No files. Sorry!'
def precmd(self, line):
print 'the user entered %s' % line
return 'dir'
def postcmd(self, stop, line):
print 'This will be dir, since we are returning that on precmd ', line
if stop:
return 'stopthis'
return line
c = MyCmd()
c.cmdloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment