16 Interactive, OurInteractive bool
19func ParseFlags() *Config {
22 flag.StringVar(&config.Code, "c", "", "execute without printing result")
23 flag.StringVar(&config.Exp, "e", "", "evaluate and print result")
25 flag.StringVar(&config.Ps1, "ps1", "--> ", "repl prompt")
26 flag.StringVar(&config.Ps2, "ps2", "... ", "repl continuation prompt")
28 flag.BoolVar(&config.Interactive, "i", false, "interactive (use language repl)")
29 flag.BoolVar(&config.OurInteractive, "I", false, "interactive (use readline repl)")
30 flag.BoolVar(&config.Quiet, "q", false, "don't print language version")
33 fmt.Fprintf(os.Stderr, "Usage: %s [FLAGS] [FILENAME]...\n", os.Args[0])
39 config.Args = flag.Args()
43func DoCli(p PluginBase) {
45 config := ParseFlags()
47 runtime.LockOSThread()
49 lang := &Language{ptr: p, ps1: config.Ps1}
52 fmt.Println(lang.Version())
55 if config.Code != "" {
56 lang.Eval(config.Code)
59 lang.EvalAndTryToPrint(config.Exp)
62 if len(config.Args) > 0 {
63 if _, err := os.Stat(config.Args[0]); os.IsNotExist(err) {
64 fmt.Println("No such file:", config.Args[0])
67 exitCode := lang.EvalFile(config.Args[0], config.Args[1:])
68 // TODO: Maybe log if exitCode is non-zero and interractive is true?
69 if exitCode != 0 && !config.Interactive && !config.OurInteractive {
75 if config.Interactive {
76 lang.SetPrompts(config.Ps1, config.Ps2)
78 } else if config.OurInteractive {
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list