mirror of
https://gitlab.com/niansa/pilang.git
synced 2025-03-06 20:48:26 +01:00
41 lines
1.4 KiB
Python
Executable file
41 lines
1.4 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
|
|
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)
|