added consistent _main

This commit is contained in:
Luxferre
2026-07-04 09:23:54 +03:00
parent bee949ccbc
commit ce18aa76b5
4 changed files with 48 additions and 8 deletions
+14 -1
View File
@@ -127,6 +127,19 @@ def clyx(f):
except Exception as e: (sys.stderr.write(f'Error executing {f}: {e}\n'), sys.exit(1))
repl = lambda: clyx(replpath)
def main(): clyx(sys.argv[1] if len(sys.argv) > 1 else replpath)
def main():
if len(sys.argv) > 1:
c = Clyx()
for f in sys.argv[1:]:
try:
with open(f) as file:
c.run(file.read())
except Exception as e:
sys.stderr.write(f'Error executing {f}: {e}\n')
sys.exit(1)
if '_main' in c._words:
c.run('_main')
else:
repl()
if __name__ == '__main__': main()