Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- running = False
- variables = {}
- functions = {}
- class Function:
- def __init__(self, name):
- self.commands = []
- def call():
- getcmdfrom(self.commands)
- class Variable:
- pass
- def getcmdfrom(command):
- global running
- args = command.split(" ")
- cmd = args[0]
- if cmd == "quit":
- running = False
- return True
- if cmd == "run":
- try:
- d = open(args[1]+".ccmd", 'r')
- except Exception:
- try:
- print(f"Error: Unable to open file \'{args[1]}\'")
- return
- except Exception:
- print(f"Usage: run <file name only>")
- return
- for c, line in enumerate(d.readlines()):
- if not getcmdfrom(line):
- print("Error: Script failed to run at line " + str(c+1) + "!")
- return True
- return True
- if cmd == "echo":
- full_msg = ""
- for c, msg in enumerate(args[1:]):
- if c < 1:
- full_msg += msg
- continue
- full_msg += " " + msg
- print(full_msg, end='\n')
- return True
- if cmd == "function":
- try:
- functions.append(Function())
- except:
- print("Usage: function <name>: <code...>")
- return False
- if __name__=='__main__':
- running = True
- while running:
- cmd = input(os.getcwd()+'>')
- if not getcmdfrom(cmd):
- print("Unknown Command.")
Advertisement
Add Comment
Please, Sign In to add comment