Created
June 22, 2015 08:38
-
-
Save prokoptsev/149b00e0c492c615ac5f 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
#!/usr/bin/env python | |
# codeing: utf-8 | |
import readline | |
import shlex | |
if __name__ == '__main__': | |
print 'Enter a command to do something, e.g. `create name price`.' | |
print 'To get help, enter `help`.' | |
while True: | |
args = shlex.split(raw_input('> ')) | |
if len(args) == 1: | |
cmd = args[0] | |
if len(args) == 3: | |
cmd, name, cost = args | |
if cmd == 'exit': | |
break | |
elif cmd == 'help': | |
print('...') | |
elif cmd == 'create': | |
cost = int(cost) | |
# ... | |
print('Created "{}", cost ${}'.format(name, cost)) | |
# ... | |
else: | |
print('Unknown command: {}'.format(cmd)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment