fibonaccios/bin/ls.py

24 lines
581 B
Python
Raw Normal View History

2022-11-29 19:46:03 -08:00
import os
def get_app_class(template):
class App(template):
def F_main(self):
2022-11-30 12:34:25 -08:00
if len(self.argv) == 1:
2022-11-30 12:50:43 -08:00
path = "."
2022-11-30 12:34:25 -08:00
else:
2022-11-30 12:50:43 -08:00
path = self.argv[1]
2022-11-30 12:34:25 -08:00
try:
2022-11-30 12:50:43 -08:00
for file in os.listdir(path):
2022-11-30 12:34:25 -08:00
print(file)
except OSError as e:
2022-11-30 12:50:43 -08:00
try:
os.stat(path)
print(path)
except OSError:
print(f"ls: cannot access '{path}': No such file or directory")
2022-11-30 12:34:25 -08:00
2022-11-29 19:46:03 -08:00
self.exit()
return App