mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 14:47:16 +09:00
allow plugins to have a help file
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user