Last active
June 28, 2017 05:05
-
-
Save ask-compu/850c1ab00a41e667b7cdeb8f2da9b426 to your computer and use it in GitHub Desktop.
This file contains 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
import sys | |
def command1(option1="Undefined", option2="Undefined"): | |
print("This is command1 with " + option1 + " and " + option2) | |
def command2(option1="Undefined", option2="Undefined"): | |
print("This is command2 with " + option1 + " and " + option2) | |
commands = {'cmd1': command1, 'cmd2': command2} | |
while True: | |
userInputraw=str(input("Please input a Command: ")) | |
if userInputraw: | |
userInput=userInputraw.split(" ") | |
if userInput[0]=="quit": | |
print("Bye!") | |
sys.exit() | |
elif userInput[0] in commands: | |
try: | |
commands[userInput[0]](*userInput[1:]) | |
except TypeError: | |
print("That was too many command options, try again") | |
continue | |
else: | |
print("Not a valid command") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment