Release 2.3.3 to master #204
23
client.go
23
client.go
|
@ -22,20 +22,6 @@ import (
|
|||
"tildegit.org/sloum/bombadillo/termios"
|
||||
)
|
||||
|
||||
var ERRS = map[string]string{
|
||||
"ADD": "`add [target] [name...]`",
|
||||
"DELETE": "`delete [bookmark-id]`",
|
||||
"BOOKMARKS": "`bookmarks [[bookmark-id]]`",
|
||||
"CHECK": "`check [link_id]` or `check [setting]`",
|
||||
"HOME": "`home`",
|
||||
"PURGE": "`purge [host]`",
|
||||
"QUIT": "`quit`",
|
||||
"RELOAD": "`reload`",
|
||||
"SEARCH": "`search [[keyword(s)...]]`",
|
||||
"SET": "`set [setting] [value]`",
|
||||
"WRITE": "`write [target]`",
|
||||
"HELP": "`help [[topic]]`",
|
||||
}
|
||||
|
||||
//------------------------------------------------\\
|
||||
// + + + T Y P E S + + + \\
|
||||
|
@ -401,8 +387,13 @@ func (c *client) doCommand(action string, values []string) {
|
|||
c.SetMessage(syntaxErrorMessage("DELETE"), true)
|
||||
c.DrawMessage()
|
||||
case "?", "HELP":
|
||||
c.SetMessage(syntaxErrorMessage("HELP"), true)
|
||||
c.DrawMessage()
|
||||
path, err := helpAddress(values[0])
|
||||
if err != nil {
|
||||
c.SetMessage(err.Error(), true)
|
||||
c.DrawMessage()
|
||||
} else {
|
||||
c.Visit(path)
|
||||
}
|
||||
case "H", "HOME":
|
||||
c.SetMessage(syntaxErrorMessage("HOME"), true)
|
||||
c.DrawMessage()
|
||||
|
|
|
@ -94,10 +94,10 @@ func (p *Parser) parseAction() (*Command, error) {
|
|||
case Value:
|
||||
cm.Target = t.val
|
||||
cm.Type = DOLINK
|
||||
case Word:
|
||||
case Word, Action:
|
||||
cm.Value = append(cm.Value, t.val)
|
||||
cm.Type = DO
|
||||
case Action, Whitespace:
|
||||
case Whitespace:
|
||||
return nil, fmt.Errorf("Found %q (%d), expected value", t.val, t.kind)
|
||||
}
|
||||
t = p.scan()
|
||||
|
|
35
help.go
Normal file
35
help.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ERRS = map[string]string{
|
||||
"ADD": "`add [target] [name...]`",
|
||||
"DELETE": "`delete [bookmark-id]`",
|
||||
"BOOKMARKS": "`bookmarks [[bookmark-id]]`",
|
||||
"CHECK": "`check [link_id]` or `check [setting]`",
|
||||
"HOME": "`home`",
|
||||
"PURGE": "`purge [host]`",
|
||||
"QUIT": "`quit`",
|
||||
"RELOAD": "`reload`",
|
||||
"SEARCH": "`search [[keyword(s)...]]`",
|
||||
"SET": "`set [setting] [value]`",
|
||||
"WRITE": "`write [target]`",
|
||||
"HELP": "`help [[topic]]`",
|
||||
}
|
||||
|
||||
var helpRoot string = "/usr/local/share/bombadillo/help"
|
||||
|
||||
func helpAddress(section string) (string, error) {
|
||||
var addr string
|
||||
switch strings.ToLower(section) {
|
||||
case "add", "a", "delete", "d", "bookmarks", "bookmark", "b":
|
||||
addr = "bookmarks.help"
|
||||
default:
|
||||
return "", fmt.Errorf("No help section for %q exists", section)
|
||||
}
|
||||
return filepath.Join(helpRoot, addr), nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user