allow plugins to have a help file

This commit is contained in:
boombuler
2016-09-13 09:06:06 +02:00
parent a7f159bddc
commit d250b9d7b0
3 changed files with 24 additions and 1 deletions

View File

@@ -1,5 +1,9 @@
package main
import (
"io/ioutil"
)
type HelpPage interface {
HelpFile() ([]byte, error)
}
@@ -19,3 +23,16 @@ type assetHelpPage string
func (file assetHelpPage) HelpFile() ([]byte, error) {
return Asset("runtime/help/" + string(file) + ".md")
}
type fileHelpPage string
func (file fileHelpPage) HelpFile() ([]byte, error) {
return ioutil.ReadFile(string(file))
}
func AddPluginHelp(name, file string) {
if _, exists := helpPages[name]; exists {
return
}
helpPages[name] = fileHelpPage(file)
}