@c4syner/

pynix

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pynix - An os written in python
from termcolor import colored

def error(err):
  print(colored(err, "red"))
def tokenize(command):
  curList = []
  curList = command.split()
  return curList


#Programs:
def echo(text = None, man = 0):
  if(man == 1):
    print("program to print desired text to terminal")
    return
  print(text)
def help():
  print("")





#Programs ^^^

#Commands:

def execProgram(commandToken):
  try:
    prog = commandToken[1]
  except IndexError: 
    error("ProgError: No program specified")
  if(len(commandToken) == 3):
    if(commandToken[1] == "echo"):
      if(commandToken[2] == "--info"):
        echo(man = 1)
      else:
        echo(commandToken[2])


def runMan():
  print("Available commands:")
  print("exec - Executes programs")
  print("help - Directs users to help menu (Current)")
  print("\nPrograms:")
  print("echo * ")
#Commands ^^^    

      

def checkCommand(commandToken):
  if(commandToken[0] == "exec"):
    execProgram(commandToken)
  elif(commandToken[0] == "help"):
    runMan()
  else:
    error("OSError: Invalid Command")

def shell():
  print("pynix v0.0.1\n")
  while(True):
    com = input(">>")
    comToken = tokenize(com)
    checkCommand(comToken)
shell()