mirror of
https://gitlab.com/niansa/pilang.git
synced 2025-03-06 20:48:26 +01:00
55 lines
1.9 KiB
Python
Executable file
55 lines
1.9 KiB
Python
Executable file
#! /usr/bin/env python3
|
|
"""
|
|
This file is part of pilang.
|
|
|
|
pilang is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
pilang is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with pilang. If not, see <https://www.gnu.org/licenses/>.
|
|
"""
|
|
import sys
|
|
from intern import main_class
|
|
|
|
if len(sys.argv) == 1: # CLI loop
|
|
# Show copyright note
|
|
print("pilang Copyright (C) 2020 niansa")
|
|
print("This program comes with ABSOLUTELY NO WARRANTY; for details type `warranty'.")
|
|
print("This is free software, and you are welcome to redistribute it")
|
|
print("under certain conditions; type `license' for details.")
|
|
print("")
|
|
# Initialise interpreter
|
|
main = main_class()
|
|
while True:
|
|
print(">>> ", end="", flush=True)
|
|
try:
|
|
commandstr = input()
|
|
except EOFError:
|
|
print()
|
|
sys.exit(0)
|
|
except KeyboardInterrupt:
|
|
print()
|
|
continue
|
|
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)
|