-
Notifications
You must be signed in to change notification settings - Fork 1
/
help.go
47 lines (37 loc) · 965 Bytes
/
help.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2014 Marcel Wouters
// Package command implements all internal commands.
// This source returns help.
package command
import (
"github.com/marcelfw/mgit/repository"
)
type cmdHelp struct {
command string
}
func NewHelpCommand() cmdHelp {
var cmd cmdHelp
return cmd
}
func (cmd cmdHelp) Usage() string {
return "Show this help information."
}
func (cmd cmdHelp) Help() string {
if cmd.command != "" {
return "There is no help about \"" + cmd.command + "\""
}
return `Show help information.
Add command as argument to help for more information about the command.`
}
func (cmd cmdHelp) Init(args []string, interactive bool) (outCmd repository.Command) {
if len(args) >= 1 {
cmd.command = args[0]
return cmd
}
return nil
}
func (cmd cmdHelp) Output(commands map[string]repository.Command, version string) string {
if helpCommand, ok := commands[cmd.command]; ok == true {
return helpCommand.Help()
}
return cmd.Help()
}