2018-07-12 10:55:13 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2018-07-16 16:21:21 +03:00
|
|
|
"flag"
|
|
|
|
"fmt"
|
2018-07-12 10:55:13 +03:00
|
|
|
"github.com/MichaelMure/git-bug/repository"
|
|
|
|
)
|
|
|
|
|
2018-07-16 16:21:21 +03:00
|
|
|
var commandsFlagSet = flag.NewFlagSet("commands", flag.ExitOnError)
|
2018-07-12 10:55:13 +03:00
|
|
|
|
2018-07-16 16:21:21 +03:00
|
|
|
var (
|
|
|
|
commandsDesc = commandsFlagSet.Bool("pretty", false, "Output the command description as well as Markdown compatible comment")
|
|
|
|
)
|
|
|
|
|
|
|
|
func runCommands(repo repository.Repo, args []string) error {
|
|
|
|
commandsFlagSet.Parse(args)
|
|
|
|
args = commandsFlagSet.Args()
|
|
|
|
|
|
|
|
first := true
|
|
|
|
|
|
|
|
for name, cmd := range CommandMap {
|
|
|
|
if !first {
|
|
|
|
fmt.Println()
|
|
|
|
}
|
|
|
|
|
|
|
|
first = false
|
|
|
|
|
|
|
|
if *commandsDesc {
|
|
|
|
fmt.Printf("# %s\n", cmd.Description)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: the root name command ("git bug") should be passed from git-bug.go but well ...
|
|
|
|
fmt.Printf("%s %s %s\n", "git bug", name, cmd.Usage)
|
|
|
|
}
|
2018-07-12 10:55:13 +03:00
|
|
|
|
2018-07-16 16:21:21 +03:00
|
|
|
return nil
|
2018-07-12 10:55:13 +03:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:21:21 +03:00
|
|
|
var commandsCmd = &Command{
|
|
|
|
Description: "Display available commands",
|
|
|
|
Usage: "[<option>...]",
|
|
|
|
flagSet: commandsFlagSet,
|
|
|
|
RunMethod: runCommands,
|
2018-07-12 10:55:13 +03:00
|
|
|
}
|