From 865c6dc23099e129cb3ba9709b2926734144e605 Mon Sep 17 00:00:00 2001 From: tjp Date: Tue, 23 Jan 2024 22:42:18 -0700 Subject: Printer abstraction --- main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index b2f5d98..695a8fc 100644 --- a/main.go +++ b/main.go @@ -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() -- cgit v1.2.3