Created
July 20, 2019 16:28
-
-
Save mw3i/151b3fb95f01a0e7fcf8f686702905f5 to your computer and use it in GitHub Desktop.
A simple shell 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
## Python Commander | |
class simple_shell(): | |
def __init__(self): | |
while True: | |
self.listener() | |
## Listener Function (required) | |
def listener(self): | |
self.user_input = input('---\nuser: ').split(' ') | |
try: | |
getattr(self, self.user_input[0])() | |
except Exception as e: | |
print(e) | |
## Commands are Python Functions you edit | |
def test(self): | |
print('this was a test command') | |
def exit(self): | |
print('exiting...') | |
exit() | |
if __name__ == '__main__': | |
print('\n\n\nhey.') | |
c = simple_shell() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment