Skip to content

Instantly share code, notes, and snippets.

@prokoptsev
Created June 22, 2015 08:38
Show Gist options
  • Save prokoptsev/149b00e0c492c615ac5f to your computer and use it in GitHub Desktop.
Save prokoptsev/149b00e0c492c615ac5f to your computer and use it in GitHub Desktop.
#!/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