aboutsummaryrefslogtreecommitdiffstats
path: root/commands/commands.go
blob: 7c4e3ab9b3e1dc2a7e9fb7c3ed050b40f06ec22f (plain) (blame)
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
// Package commands contains the assorted sub commands supported by the git-bug tool.
package commands

import (
	"github.com/MichaelMure/git-bug/repository"
)

const messageFilename = "BUG_MESSAGE_EDITMSG"

// Command represents the definition of a single command.
type Command struct {
	Usage     func(string)
	RunMethod func(repository.Repo, []string) error
}

// Run executes a command, given its arguments.
//
// The args parameter is all of the command line args that followed the
// subcommand.
func (cmd *Command) Run(repo repository.Repo, args []string) error {
	return cmd.RunMethod(repo, args)
}

// CommandMap defines all of the available (sub)commands.
var CommandMap = map[string]*Command{
	"ls":   lsCmd,
	"new":  newCmd,
	"pull": pullCmd,
	"push": pushCmd,
}