commands.go

 1// Package commands contains the assorted sub commands supported by the git-bug tool.
 2package commands
 3
 4import (
 5	"github.com/MichaelMure/git-bug/repository"
 6)
 7
 8const messageFilename = "BUG_MESSAGE_EDITMSG"
 9
10// Command represents the definition of a single command.
11type Command struct {
12	Usage     func(string)
13	RunMethod func(repository.Repo, []string) error
14}
15
16// Run executes a command, given its arguments.
17//
18// The args parameter is all of the command line args that followed the
19// subcommand.
20func (cmd *Command) Run(repo repository.Repo, args []string) error {
21	return cmd.RunMethod(repo, args)
22}
23
24// CommandMap defines all of the available (sub)commands.
25var CommandMap = map[string]*Command{
26	"ls":   lsCmd,
27	"new":  newCmd,
28	"pull": pullCmd,
29	"push": pushCmd,
30}