Created
November 5, 2014 22:31
-
-
Save pbassut/ce36e4f3008ab8e90814 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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