An operating system for CircuitPython devices
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.3 KiB

import fibonaccios.exceptions
1 year ago
import shlex
import console
1 year ago
def get_app_class(template):
class App(template):
def F_main(self):
self.jump('prompt')
1 year ago
1 year ago
def F_prompt(self):
1 year ago
console.print(self.console, 'FibonacciOS sh # ', end="")
1 year ago
self.store['buf'] = []
self.jump('input')
1 year ago
1 year ago
def F_input(self):
try:
raw_line = console.read(self.console, self.store['buf'])
except EOFError:
self.exit()
return
1 year ago
if raw_line is not None:
line = shlex.split(raw_line.decode('ascii'))
if line:
try:
if line[0] == 'bg':
self.launch(*line[1:])
elif line[0] == 'cd':
self.chdir(line[1])
1 year ago
elif line[0] == 'exit':
self.exit()
else:
pid = self.launch(*line)
1 year ago
self.wait(pid)
self.transfer_console(pid)
except fibonaccios.exceptions.AppNotFound as e:
1 year ago
console.print(self.console, 'error: app not found')
1 year ago
self.jump('prompt')
1 year ago
1 year ago
return App