noether/py/noether.py

34 lines
916 B
Python

from noether.cli.style import *
from noether.cli.prompt import *
from noether.lib.structs import Result
class Noether(Prompt):
DEFAULT_PROMPT = style('~>> ', Color.BLUE)
def __init__(self) -> None:
super().__init__()
def _parse(self, command: str) -> int:
try:
return Result.succeed(int(command))
except ValueError:
return Result.fail('Not an integer.')
def _exec(self, command: int) -> None:
print(style(f'OMG {command}', Color.CYAN))
def main():
try:
noether = Noether()
while True:
noether.prompt()
except (KeyboardInterrupt, EOFError):
err = style('Exit Requested...', Effect.ITALICS)
print('\n', style('[!]', Color.RED), err)
if __name__ == '__main__':
try:
main()
except (KeyboardInterrupt, EOFError):
# handles premature SIGINT/EOF
pass