Split help into multiple files and add help command

This commit is contained in:
Zachary Yedidia
2016-07-28 15:52:31 -04:00
parent cb79e08f19
commit 4a0c48587a
10 changed files with 404 additions and 258 deletions

View File

@@ -24,6 +24,7 @@ var commandActions = map[string]func([]string){
"VSplit": VSplit,
"HSplit": HSplit,
"Tab": NewTab,
"Help": Help,
}
// InitCommands initializes the default commands
@@ -65,6 +66,22 @@ func DefaultCommands() map[string]string {
"vsplit": "VSplit",
"hsplit": "HSplit",
"tab": "Tab",
"help": "Help",
}
}
// Help tries to open the given help page in a horizontal split
func Help(args []string) {
if len(args) < 1 {
// Open the default help if the user just typed "> help"
CurView().openHelp("help")
} else {
helpPage := args[0]
if _, ok := helpPages[helpPage]; ok {
CurView().openHelp(helpPage)
} else {
messenger.Error("Sorry, no help for ", helpPage)
}
}
}