Skip to content

Instantly share code, notes, and snippets.

@KevinAlavik
Created June 23, 2023 08:31
Show Gist options
  • Save KevinAlavik/14012690888868400ea8d0db838d29c0 to your computer and use it in GitHub Desktop.
Save KevinAlavik/14012690888868400ea8d0db838d29c0 to your computer and use it in GitHub Desktop.
Simple interactive cli made in python
import sys
import os
def help():
print("Available commands:")
for command in commands:
print(" - " + command)
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
commands = {
"help": help,
"exit": sys.exit,
"clear": clear
}
while True:
command = input("> ")
if command in commands:
commands[command]()
else:
print("Invalid command.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment