forked from cwtch.im/cwtch
1
0
Fork 0

Bugfixes for #99

clifix
Sarah Jamie Lewis 4 years ago
parent 8764417b0e
commit 437c12db75
  1. 22
      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"])

Loading…
Cancel
Save