1
0
Fork 0
mirror of https://gitlab.com/niansa/pilang.git synced 2025-03-06 20:48:26 +01:00
pilang/cli.py
2020-04-09 23:44:06 +02:00

25 lines
780 B
Python
Executable file

#! /usr/bin/env python3
import sys
from intern import main_class
if len(sys.argv) == 1: # CLI loop
main = main_class()
while True:
print(">>> ", end="", flush=True)
commandstr = input()
res = main.get_rstring(main.run_command(commandstr), errorsonly=False)
if res != None:
print(res)
else: # File execution loop
main = main_class()
if sys.argv[1] == "-c":
del sys.argv[1]
if len(sys.argv[1]) == 1:
sys.exit(1)
with open(sys.argv[1], mode="r") as f:
for line in f:
if line[-1] == "\n":
line = line[:-1]
cmdres = main.get_rstring(main.run_command(line), errorsonly=True)
if cmdres:
print(cmdres)