diff options
| author | tjp <tjp@ctrl-c.club> | 2024-01-23 22:42:18 -0700 |
|---|---|---|
| committer | tjp <tjp@ctrl-c.club> | 2024-01-23 22:42:18 -0700 |
| commit | 865c6dc23099e129cb3ba9709b2926734144e605 (patch) | |
| tree | 6824a2de82e842ea79554b581ceb0db328235c46 /main.go | |
| parent | dd2a06c1e1391fe6242015330b7c61fa37fd67cc (diff) | |
Printer abstraction
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -44,14 +44,8 @@ func main() { state.Quiet = true } - if urls := flag.Args(); len(urls) > 0 { - if err := Go(state, urls[0]); err != nil { - writeError(err.Error()) - } - } - - // runInteractivePrompt(state) - runTUI(state) + runInteractivePrompt(state, flag.Args()) + // runTUI(state, flag.Args()) } func buildReadline(prompt string, conf *Config) (*readline.Instance, error) { @@ -106,7 +100,15 @@ func buildInitialState() (*BrowserState, error) { return state, nil } -func runInteractivePrompt(state *BrowserState) { +func runInteractivePrompt(state *BrowserState, args []string) { + state.Printer = PromptPrinter{} + + if len(args) > 0 { + if err := Go(state, args[0]); err != nil { + writeError(err.Error()) + } + } + for { state.Readline.SetPrompt(Prompt) line, err := state.Readline.Readline() |
