fibonaccios/bin/cat.py

21 lines
638 B
Python

import os
import console
def get_app_class(template):
class App(template):
def F_main(self):
for file in self.argv[1:]:
try:
with open(file, "rb") as f:
self.console.write(f.read())
except OSError as e:
try:
os.listdir(file)
console.write_str(self.console, f"cat: {file}: Is a directory\n")
except OSError:
console.write_str(self.console, f"cat: {file}: No such file or directory\n")
self.exit()
return App