Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from ansicolors import BOLD 

2from ansicolors import RED 

3from ansicolors import RESET 

4from argparse import Parser 

5from argparse import ValueType 

6from os import OsError 

7from os.path import Path 

8from os.tty import is_tty 

9from os.tty import set_to_cbreak_mode 

10from . import execute 

11 

12func main(argv: [string]): 

13 parser = Parser(version=__version__, 

14 help="A Brainfuck interpreter.") 

15 parser.add_positional("program", 

16 value_type=ValueType.Path, 

17 help="Program path.") 

18 args = parser.parse(argv) 

19 

20 try: 

21 source = Path(args.value_of("program")).read_text() 

22 

23 if is_tty(0): 

24 set_to_cbreak_mode(0) 

25 

26 execute(source) 

27 except OsError as error: 

28 raise SystemExitError(f"{RED}{BOLD}error{RESET}: {error.message}")