From 437c12db7555c9a41d9e7c55443b27be3e376ab0 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Sat, 4 Aug 2018 14:19:11 -0700 Subject: [PATCH] Bugfixes for #99 --- app/cli/main.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/cli/main.go b/app/cli/main.go index f2c5fea..ce070c1 100644 --- a/app/cli/main.go +++ b/app/cli/main.go @@ -66,14 +66,14 @@ func completer(d prompt.Document) []prompt.Suggest { var s []prompt.Suggest - if app.Peer == nil { - return s - } - if d.FindStartOfPreviousWord() == 0 { return prompt.FilterHasPrefix(suggestions, d.GetWordBeforeCursor(), true) } + if app.Peer == nil { + return s + } + w := d.CurrentLine() if strings.HasPrefix(w, "send") || strings.HasPrefix(w, "timeline") || strings.HasPrefix(w, "export-group") { s = []prompt.Suggest{} @@ -202,9 +202,19 @@ func main() { commands := strings.Split(text[0:], " ") history = append(history, text) + + if app.Peer == nil { + if commands[0] != "help" && commands[0] != "quit" && commands[0] != "new-profile" && commands[0] != "load-profile" { + fmt.Printf("Profile needs to be set\n") + continue + } + } + switch commands[0] { case "quit": - app.Peer.Save() + if app.Peer != nil { + app.Peer.Save() + } quit = true case "new-profile": if len(commands) == 2 { @@ -250,7 +260,7 @@ func main() { if err == nil { fmt.Printf("\nLoaded profile for %v\n", commands[1]) } else { - fmt.Printf("Error loading profile for %v: %v\n", commands[1], err) + fmt.Printf("\nError loading profile for %v: %v\n", commands[1], err) } } else { fmt.Printf("Error Loading profile, usage: %s\n", usages["load-profile"])