summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authortjp <tjp@ctrl-c.club>2024-01-23 22:42:18 -0700
committertjp <tjp@ctrl-c.club>2024-01-23 22:42:18 -0700
commit865c6dc23099e129cb3ba9709b2926734144e605 (patch)
tree6824a2de82e842ea79554b581ceb0db328235c46 /main.go
parentdd2a06c1e1391fe6242015330b7c61fa37fd67cc (diff)
Printer abstraction
Diffstat (limited to 'main.go')
-rw-r--r--main.go20
1 files changed, 11 insertions, 9 deletions
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()