MisterBasic

Blixate Console

Sep 22nd, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. import os
  2. import sys
  3. running = False
  4.  
  5. variables = {}
  6. functions = {}
  7.  
  8. class Function:
  9.     def __init__(self, name):
  10.         self.commands = []
  11.     def call():
  12.         getcmdfrom(self.commands)
  13. class Variable:
  14.     pass
  15.  
  16. def getcmdfrom(command):
  17.     global running
  18.     args = command.split(" ")
  19.     cmd = args[0]
  20.     if cmd == "quit":
  21.         running = False
  22.         return True
  23.     if cmd == "run":
  24.         try:
  25.             d = open(args[1]+".ccmd", 'r')
  26.         except Exception:
  27.             try:
  28.                 print(f"Error: Unable to open file \'{args[1]}\'")
  29.                 return
  30.             except Exception:
  31.                 print(f"Usage: run <file name only>")
  32.                 return
  33.         for c, line in enumerate(d.readlines()):
  34.             if not getcmdfrom(line):
  35.                 print("Error: Script failed to run at line " + str(c+1) + "!")
  36.                 return True
  37.         return True
  38.     if cmd == "echo":
  39.         full_msg = ""
  40.         for c, msg in enumerate(args[1:]):
  41.             if c < 1:
  42.                 full_msg += msg
  43.                 continue
  44.             full_msg += " " + msg
  45.         print(full_msg, end='\n')
  46.         return True
  47.     if cmd == "function":
  48.         try:
  49.             functions.append(Function())
  50.         except:
  51.             print("Usage: function <name>: <code...>")
  52.     return False
  53.  
  54. if __name__=='__main__':
  55.     running = True
  56.     while running:
  57.         cmd = input(os.getcwd()+'>')
  58.         if not getcmdfrom(cmd):
  59.             print("Unknown Command.")
Advertisement
Add Comment
Please, Sign In to add comment