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 bugsRefPattern = "refs/bugs/*"
 9const messageFilename = "BUG_MESSAGE_EDITMSG"
10
11// Command represents the definition of a single command.
12type Command struct {
13	Usage     func(string)
14	RunMethod func(repository.Repo, []string) error
15}
16
17// Run executes a command, given its arguments.
18//
19// The args parameter is all of the command line args that followed the
20// subcommand.
21func (cmd *Command) Run(repo repository.Repo, args []string) error {
22	return cmd.RunMethod(repo, args)
23}
24
25// CommandMap defines all of the available (sub)commands.
26var CommandMap = map[string]*Command{
27	"new":  newCmd,
28	"pull": pullCmd,
29	"push": pushCmd,
30}