cairde/ui/input.go

46 lines
1.2 KiB
Go

package ui
import (
"strings"
)
const unknownCmdHelp = "Unknown command? Run /help to see available commands"
const cmdHelp = `/acn on | Turn on the Tor ACN
/acn off | Turn off the Tor ACN
/clear | Clear the screen
/help | Show this help
/profile create <name> <password> <password> | Create a new profile
/profile info | Show profile information
/profile unlock <password> | Unlock profile(s)
/start | Show getting started guide
/quit | Quit the program`
func hidePasswordInput(m *model) {
val := m.input.Value()
if len(val) == 0 {
return
}
if string(val[0]) != "/" {
return
}
cmds := strings.Split(val[1:], " ")
if !(cmds[0] == "profile" && len(cmds) >= 2) {
return
}
if cmds[1] == "create" && len(cmds) > 3 ||
cmds[1] == "unlock" && len(cmds) > 2 {
lastChar := string(val[len(val)-1])
m.hiddenInput += lastChar
if lastChar != " " {
newCmd := []rune(val)
newCmd[len(val)-1] = '*'
m.input.SetValue(string(newCmd))
}
}
}