Skip to content

Commit 8c3613b

Browse files
authored
Create main.py
1 parent af4cda4 commit 8c3613b

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

CoreShell/main.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import os
2+
import importlib
3+
from bin import *
4+
import colours
5+
6+
home = os.getcwd()
7+
8+
validCmds = []
9+
10+
def execute_command(cmd, args):
11+
try:
12+
command_func = globals().get(cmd) or importlib.import_module(f"bin.{cmd}")
13+
output = command_func(args)
14+
return output
15+
except Exception as e:
16+
return f"Error: {e}"
17+
18+
while True:
19+
wd=""
20+
cmd=""
21+
base=""
22+
args=""
23+
24+
wd = os.getcwd()
25+
cmd = input(wd + colours.magenta() + " ~ € " + colours.reset())
26+
base = cmd.split(" ")[0]
27+
args = cmd.split(" ")[1:]
28+
if base not in globals() and not hasattr(importlib.import_module('bin'), base):
29+
print("Command not found.")
30+
else:
31+
output = execute_command(base, args)
32+
if output not in [0, None]:
33+
print(output)

0 commit comments

Comments
 (0)