bombadillo/help.go

74 lines
1.9 KiB
Go
Raw Normal View History

2020-06-21 17:16:05 +00:00
package main
import (
"fmt"
"os"
2020-06-21 17:16:05 +00:00
"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"
2020-06-21 22:53:31 +00:00
case "quit", "quitting", "q", "flags", "runtime", "options", "exiting", "exit", "general", "startup", "version", "title":
addr = "general.help"
case "help", "info", "?", "information":
addr = "help.help"
case "write", "save", "saving", "w", "file", "writing", "download", "downloading", "downloads":
addr = "saving.help"
case "license":
addr = "license.help"
2020-07-17 05:05:37 +00:00
case "local", "file":
addr = "local.help"
2020-06-24 03:31:32 +00:00
case "finger":
addr = "finger.help"
2020-07-17 05:05:37 +00:00
case "gemini", "text/gemini", "tls", "tofu":
2020-06-24 03:31:32 +00:00
addr = "gemini.help"
2020-07-02 18:37:00 +00:00
case "gopher":
addr = "gopher.help"
2020-06-24 03:31:32 +00:00
case "keys", "key", "hotkeys", "hotkey", "keymap", "controls":
addr = "keys.help"
2020-07-02 18:37:00 +00:00
case "telnet":
addr = "telnet.help"
case "navigating", "navigation", "scroll", "scrolling", "history","links", "link":
addr = "navigation.help"
case "command", "commands", "functions":
addr = "commands.help"
2020-07-17 05:05:37 +00:00
case "protocol", "protocols":
addr = "protocols.help"
case "resources", "links":
addr = "resources.go"
2020-06-21 17:16:05 +00:00
default:
return "", fmt.Errorf("No help section for %q exists", section)
}
fp := filepath.Join(helpRoot, addr)
_, err := os.Stat(fp)
if err != nil {
return "", fmt.Errorf("No help section for %q exists", section)
}
return fp, nil
2020-06-21 17:16:05 +00:00
}