2022-11-29 19:46:03 -08:00
|
|
|
import os
|
2022-11-30 19:33:05 -08:00
|
|
|
import console
|
2022-11-29 19:46:03 -08:00
|
|
|
|
|
|
|
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-12-01 12:19:32 -08:00
|
|
|
console.print(self.console, file)
|
2022-11-30 12:34:25 -08:00
|
|
|
except OSError as e:
|
2022-11-30 12:50:43 -08:00
|
|
|
try:
|
|
|
|
os.stat(path)
|
2022-12-01 12:19:32 -08:00
|
|
|
console.print(self.console, path)
|
2022-11-30 12:50:43 -08:00
|
|
|
except OSError:
|
2022-12-01 12:19:32 -08:00
|
|
|
console.print(self.console, 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
|