Created
June 23, 2023 08:31
-
-
Save KevinAlavik/14012690888868400ea8d0db838d29c0 to your computer and use it in GitHub Desktop.
Simple interactive cli made in python
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
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