fibonaccios/bin/ls.py
2022-11-30 18:11:02 -08:00

24 lines
620 B
Python

import os
def get_app_class(template):
class App(template):
def F_main(self):
if len(self.argv) == 1:
path = "."
else:
path = self.argv[1]
try:
for file in os.listdir(path):
self.console.write(file)
except OSError as e:
try:
os.stat(path)
self.console.write(path)
except OSError:
self.console.write(f"ls: cannot access '{path}': No such file or directory")
self.exit()
return App