Fixes help to take an optional action as a value to get syntax for a given command
This commit is contained in:
parent
7dc68a18bf
commit
89095351a8
10
client.go
10
client.go
|
@ -344,7 +344,7 @@ func (c *client) simpleCommand(action string) {
|
||||||
case "SEARCH":
|
case "SEARCH":
|
||||||
c.search("", "", "?")
|
c.search("", "", "?")
|
||||||
case "HELP", "?":
|
case "HELP", "?":
|
||||||
go c.Visit(helplocation)
|
c.Visit(helplocation)
|
||||||
default:
|
default:
|
||||||
c.SetMessage(syntaxErrorMessage(action), true)
|
c.SetMessage(syntaxErrorMessage(action), true)
|
||||||
c.DrawMessage()
|
c.DrawMessage()
|
||||||
|
@ -356,6 +356,14 @@ func (c *client) doCommand(action string, values []string) {
|
||||||
case "C", "CHECK":
|
case "C", "CHECK":
|
||||||
c.displayConfigValue(values[0])
|
c.displayConfigValue(values[0])
|
||||||
c.DrawMessage()
|
c.DrawMessage()
|
||||||
|
case "HELP", "?":
|
||||||
|
if val, ok := ERRS[values[0]]; ok {
|
||||||
|
c.SetMessage(val, false)
|
||||||
|
} else {
|
||||||
|
msg := fmt.Sprintf("%q is not a valid command; help syntax: %s", values[0], ERRS[action])
|
||||||
|
c.SetMessage(msg, false)
|
||||||
|
}
|
||||||
|
c.DrawMessage()
|
||||||
case "PURGE", "P":
|
case "PURGE", "P":
|
||||||
err := c.Certs.Purge(values[0])
|
err := c.Certs.Purge(values[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -94,10 +94,10 @@ func (p *Parser) parseAction() (*Command, error) {
|
||||||
case Value:
|
case Value:
|
||||||
cm.Target = t.val
|
cm.Target = t.val
|
||||||
cm.Type = DOLINK
|
cm.Type = DOLINK
|
||||||
case Word:
|
case Word, Action:
|
||||||
cm.Value = append(cm.Value, t.val)
|
cm.Value = append(cm.Value, t.val)
|
||||||
cm.Type = DO
|
cm.Type = DO
|
||||||
case Action, Whitespace:
|
case Whitespace:
|
||||||
return nil, fmt.Errorf("Found %q (%d), expected value", t.val, t.kind)
|
return nil, fmt.Errorf("Found %q (%d), expected value", t.val, t.kind)
|
||||||
}
|
}
|
||||||
t = p.scan()
|
t = p.scan()
|
||||||
|
|
4
help.go
4
help.go
|
@ -23,6 +23,6 @@ var ERRS = map[string]string{
|
||||||
"SET": "`set [setting] [value]`",
|
"SET": "`set [setting] [value]`",
|
||||||
"W": "`w [target]`",
|
"W": "`w [target]`",
|
||||||
"WRITE": "`write [target]`",
|
"WRITE": "`write [target]`",
|
||||||
"?": "`?`",
|
"?": "`? [[command]]`",
|
||||||
"HELP": "`help`",
|
"HELP": "`help [[command]]`",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue