Skip to content

Instantly share code, notes, and snippets.

@The-Quill
Last active September 23, 2016 03:20
Show Gist options
  • Save The-Quill/91170ab40e5f9a8b2aa0b6e73df7d593 to your computer and use it in GitHub Desktop.
Save The-Quill/91170ab40e5f9a8b2aa0b6e73df7d593 to your computer and use it in GitHub Desktop.
A basic command prompt style thing for Python
def ls(params):
# do whatever
return True
commands = {
'ls': ls,
# ... whatever here
}
while True:
content = raw_input().split(' ')
command = content[0]
params = content[1:]
print('you ran the "{name}" command'.format(name=command))
if command == 'quit':
break;
if command in commands:
commands[command](params)
else:
print('the command "{name}" doesn\'t exist'.format(name=command))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment