diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-19 12:30:25 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-19 12:36:01 +0200 |
commit | 7f5922f905831a85ffee4c9226b65715899ba758 (patch) | |
tree | d18a29a2ec13706efa7f5e9efc9515a92cf4513d /commands/command.go | |
parent | 459bb8747d9e84493b8d04a3172e6758452a75b9 (diff) | |
download | git-bug-7f5922f905831a85ffee4c9226b65715899ba758.tar.gz |
rework all the commands to use cobra as a parser
Diffstat (limited to 'commands/command.go')
-rw-r--r-- | commands/command.go | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/commands/command.go b/commands/command.go deleted file mode 100644 index 89420b46..00000000 --- a/commands/command.go +++ /dev/null @@ -1,59 +0,0 @@ -// Package commands contains the assorted sub commands supported by the git-bug tool. -package commands - -import ( - "flag" - "fmt" - "github.com/MichaelMure/git-bug/repository" -) - -const messageFilename = "BUG_MESSAGE_EDITMSG" - -// Command represents the definition of a single command. -type Command struct { - // Short description of the command - Description string - // Command line usage - Usage string - // Flag set of the command - flagSet *flag.FlagSet - // Execute the command - 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) -} - -func (cmd *Command) PrintUsage(rootCommand string, cmdName string) { - fmt.Printf("Usage: %s %s %s\n", rootCommand, cmdName, cmd.Usage) - - if cmd.flagSet != nil { - fmt.Printf("\nOptions:\n") - cmd.flagSet.PrintDefaults() - } -} - -// CommandMap defines all of the available (sub)commands. -var CommandMap map[string]*Command - -// We use init() to avoid a cycle in the data initialization because of the "commands" command -func init() { - CommandMap = map[string]*Command{ - "close": closeCmd, - "commands": commandsCmd, - "comment": commentCmd, - "label": labelCmd, - "ls": lsCmd, - "new": newCmd, - "open": openCmd, - "pull": pullCmd, - "push": pushCmd, - "show": showCmd, - "webui": webUICmd, - } -} |