diff options
-rw-r--r-- | commands/bridge.go | 38 | ||||
-rw-r--r-- | commands/bridge_configure.go | 95 | ||||
-rw-r--r-- | commands/select/select_test.go | 3 | ||||
-rw-r--r-- | doc/man/git-bug-bridge-bridge.1 | 29 | ||||
-rw-r--r-- | doc/man/git-bug-bridge-configure.1 | 29 | ||||
-rw-r--r-- | doc/man/git-bug-bridge.1 | 29 | ||||
-rw-r--r-- | doc/man/git-bug.1 | 2 | ||||
-rw-r--r-- | doc/md/git-bug.md | 1 | ||||
-rw-r--r-- | doc/md/git-bug_bridge.md | 23 | ||||
-rw-r--r-- | doc/md/git-bug_bridge_bridge.md | 22 | ||||
-rw-r--r-- | doc/md/git-bug_bridge_configure.md | 22 | ||||
-rw-r--r-- | misc/bash_completion/git-bug | 42 | ||||
-rw-r--r-- | misc/zsh_completion/git-bug | 5 |
13 files changed, 335 insertions, 5 deletions
diff --git a/commands/bridge.go b/commands/bridge.go new file mode 100644 index 00000000..93b5991b --- /dev/null +++ b/commands/bridge.go @@ -0,0 +1,38 @@ +package commands + +import ( + "fmt" + + "github.com/MichaelMure/git-bug/bridge" + "github.com/MichaelMure/git-bug/cache" + "github.com/spf13/cobra" +) + +func runBridge(cmd *cobra.Command, args []string) error { + backend, err := cache.NewRepoCache(repo) + if err != nil { + return err + } + defer backend.Close() + + configured, err := bridge.ConfiguredBridges(backend) + if err != nil { + return err + } + + for _, c := range configured { + fmt.Println(c) + } + + return nil +} + +var bridgeCmd = &cobra.Command{ + Use: "bridge", + Short: "Configure and use bridges to other bug trackers", + RunE: runBridge, +} + +func init() { + RootCmd.AddCommand(bridgeCmd) +} diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go new file mode 100644 index 00000000..564affcc --- /dev/null +++ b/commands/bridge_configure.go @@ -0,0 +1,95 @@ +package commands + +import ( + "bufio" + "fmt" + "os" + "strings" + + "github.com/MichaelMure/git-bug/bridge" + "github.com/MichaelMure/git-bug/bridge/core" + "github.com/MichaelMure/git-bug/cache" + "github.com/spf13/cobra" +) + +func runBridgeConfigure(cmd *cobra.Command, args []string) error { + backend, err := cache.NewRepoCache(repo) + if err != nil { + return err + } + defer backend.Close() + + target, err := promptTarget() + if err != nil { + return err + } + + name, err := promptName() + if err != nil { + return err + } + + b, err := core.NewBridge(backend, target, name) + if err != nil { + return err + } + + err = b.Configure() + if err != nil { + return err + } + + return nil +} + +func promptTarget() (string, error) { + targets := bridge.Targets() + + for { + fmt.Printf("target (%s): ", strings.Join(targets, ",")) + + line, err := bufio.NewReader(os.Stdin).ReadString('\n') + if err != nil { + return "", err + } + + line = strings.TrimRight(line, "\n") + + for _, t := range targets { + if t == line { + return t, nil + } + } + + fmt.Println("invalid target") + } +} + +func promptName() (string, error) { + defaultName := "default" + + fmt.Printf("name [%s]: ", defaultName) + + line, err := bufio.NewReader(os.Stdin).ReadString('\n') + if err != nil { + return "", err + } + + line = strings.TrimRight(line, "\n") + + if line == "" { + return defaultName, nil + } + + return line, nil +} + +var bridgeConfigureCmd = &cobra.Command{ + Use: "configure", + Short: "Configure a new bridge", + RunE: runBridgeConfigure, +} + +func init() { + bridgeCmd.AddCommand(bridgeConfigureCmd) +} diff --git a/commands/select/select_test.go b/commands/select/select_test.go index 5a34d71e..79c8cbf0 100644 --- a/commands/select/select_test.go +++ b/commands/select/select_test.go @@ -1,7 +1,6 @@ package _select import ( - "fmt" "io/ioutil" "log" "testing" @@ -92,8 +91,6 @@ func createRepo() *repository.GitRepo { log.Fatal(err) } - fmt.Println("Creating repo:", dir) - repo, err := repository.InitGitRepo(dir) if err != nil { log.Fatal(err) diff --git a/doc/man/git-bug-bridge-bridge.1 b/doc/man/git-bug-bridge-bridge.1 new file mode 100644 index 00000000..edd0a5d3 --- /dev/null +++ b/doc/man/git-bug-bridge-bridge.1 @@ -0,0 +1,29 @@ +.TH "GIT-BUG" "1" "Sep 2018" "Generated from git-bug's source code" "" +.nh +.ad l + + +.SH NAME +.PP +git\-bug\-bridge\-bridge \- Configure and use bridges to other bug trackers + + +.SH SYNOPSIS +.PP +\fBgit\-bug bridge bridge [flags]\fP + + +.SH DESCRIPTION +.PP +Configure and use bridges to other bug trackers + + +.SH OPTIONS +.PP +\fB\-h\fP, \fB\-\-help\fP[=false] + help for bridge + + +.SH SEE ALSO +.PP +\fBgit\-bug\-bridge(1)\fP diff --git a/doc/man/git-bug-bridge-configure.1 b/doc/man/git-bug-bridge-configure.1 new file mode 100644 index 00000000..488b2a8a --- /dev/null +++ b/doc/man/git-bug-bridge-configure.1 @@ -0,0 +1,29 @@ +.TH "GIT-BUG" "1" "Sep 2018" "Generated from git-bug's source code" "" +.nh +.ad l + + +.SH NAME +.PP +git\-bug\-bridge\-configure \- Configure a new bridge + + +.SH SYNOPSIS +.PP +\fBgit\-bug bridge configure [flags]\fP + + +.SH DESCRIPTION +.PP +Configure a new bridge + + +.SH OPTIONS +.PP +\fB\-h\fP, \fB\-\-help\fP[=false] + help for configure + + +.SH SEE ALSO +.PP +\fBgit\-bug\-bridge(1)\fP diff --git a/doc/man/git-bug-bridge.1 b/doc/man/git-bug-bridge.1 new file mode 100644 index 00000000..c5720413 --- /dev/null +++ b/doc/man/git-bug-bridge.1 @@ -0,0 +1,29 @@ +.TH "GIT-BUG" "1" "Sep 2018" "Generated from git-bug's source code" "" +.nh +.ad l + + +.SH NAME +.PP +git\-bug\-bridge \- Configure and use bridges to other bug trackers + + +.SH SYNOPSIS +.PP +\fBgit\-bug bridge [flags]\fP + + +.SH DESCRIPTION +.PP +Configure and use bridges to other bug trackers + + +.SH OPTIONS +.PP +\fB\-h\fP, \fB\-\-help\fP[=false] + help for bridge + + +.SH SEE ALSO +.PP +\fBgit\-bug(1)\fP, \fBgit\-bug\-bridge\-configure(1)\fP diff --git a/doc/man/git-bug.1 b/doc/man/git-bug.1 index 41a29799..0a15711a 100644 --- a/doc/man/git-bug.1 +++ b/doc/man/git-bug.1 @@ -29,4 +29,4 @@ It use the same internal storage so it doesn't pollute your project. As you woul .SH SEE ALSO .PP -\fBgit\-bug\-add(1)\fP, \fBgit\-bug\-commands(1)\fP, \fBgit\-bug\-comment(1)\fP, \fBgit\-bug\-label(1)\fP, \fBgit\-bug\-ls(1)\fP, \fBgit\-bug\-ls\-label(1)\fP, \fBgit\-bug\-pull(1)\fP, \fBgit\-bug\-push(1)\fP, \fBgit\-bug\-select(1)\fP, \fBgit\-bug\-show(1)\fP, \fBgit\-bug\-status(1)\fP, \fBgit\-bug\-termui(1)\fP, \fBgit\-bug\-title(1)\fP, \fBgit\-bug\-webui(1)\fP +\fBgit\-bug\-add(1)\fP, \fBgit\-bug\-bridge(1)\fP, \fBgit\-bug\-commands(1)\fP, \fBgit\-bug\-comment(1)\fP, \fBgit\-bug\-label(1)\fP, \fBgit\-bug\-ls(1)\fP, \fBgit\-bug\-ls\-label(1)\fP, \fBgit\-bug\-pull(1)\fP, \fBgit\-bug\-push(1)\fP, \fBgit\-bug\-select(1)\fP, \fBgit\-bug\-show(1)\fP, \fBgit\-bug\-status(1)\fP, \fBgit\-bug\-termui(1)\fP, \fBgit\-bug\-title(1)\fP, \fBgit\-bug\-webui(1)\fP diff --git a/doc/md/git-bug.md b/doc/md/git-bug.md index 3d0592c9..af4859ce 100644 --- a/doc/md/git-bug.md +++ b/doc/md/git-bug.md @@ -21,6 +21,7 @@ git-bug [flags] ### SEE ALSO * [git-bug add](git-bug_add.md) - Create a new bug +* [git-bug bridge](git-bug_bridge.md) - Configure and use bridges to other bug trackers * [git-bug commands](git-bug_commands.md) - Display available commands * [git-bug comment](git-bug_comment.md) - Display or add comments * [git-bug label](git-bug_label.md) - Display, add or remove labels diff --git a/doc/md/git-bug_bridge.md b/doc/md/git-bug_bridge.md new file mode 100644 index 00000000..ce4f6d6d --- /dev/null +++ b/doc/md/git-bug_bridge.md @@ -0,0 +1,23 @@ +## git-bug bridge + +Configure and use bridges to other bug trackers + +### Synopsis + +Configure and use bridges to other bug trackers + +``` +git-bug bridge [flags] +``` + +### Options + +``` + -h, --help help for bridge +``` + +### SEE ALSO + +* [git-bug](git-bug.md) - A bug tracker embedded in Git +* [git-bug bridge configure](git-bug_bridge_configure.md) - Configure a new bridge + diff --git a/doc/md/git-bug_bridge_bridge.md b/doc/md/git-bug_bridge_bridge.md new file mode 100644 index 00000000..d5803190 --- /dev/null +++ b/doc/md/git-bug_bridge_bridge.md @@ -0,0 +1,22 @@ +## git-bug bridge bridge + +Configure and use bridges to other bug trackers + +### Synopsis + +Configure and use bridges to other bug trackers + +``` +git-bug bridge bridge [flags] +``` + +### Options + +``` + -h, --help help for bridge +``` + +### SEE ALSO + +* [git-bug bridge](git-bug_bridge.md) - Configure and use bridges to other bug trackers + diff --git a/doc/md/git-bug_bridge_configure.md b/doc/md/git-bug_bridge_configure.md new file mode 100644 index 00000000..ca66f500 --- /dev/null +++ b/doc/md/git-bug_bridge_configure.md @@ -0,0 +1,22 @@ +## git-bug bridge configure + +Configure a new bridge + +### Synopsis + +Configure a new bridge + +``` +git-bug bridge configure [flags] +``` + +### Options + +``` + -h, --help help for configure +``` + +### SEE ALSO + +* [git-bug bridge](git-bug_bridge.md) - Configure and use bridges to other bug trackers + diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug index c78391dd..88f2e871 100644 --- a/misc/bash_completion/git-bug +++ b/misc/bash_completion/git-bug @@ -277,6 +277,47 @@ _git-bug_add() noun_aliases=() } +_git-bug_bridge_configure() +{ + last_command="git-bug_bridge_configure" + + command_aliases=() + + commands=() + + flags=() + two_word_flags=() + local_nonpersistent_flags=() + flags_with_completion=() + flags_completion=() + + + must_have_one_flag=() + must_have_one_noun=() + noun_aliases=() +} + +_git-bug_bridge() +{ + last_command="git-bug_bridge" + + command_aliases=() + + commands=() + commands+=("configure") + + flags=() + two_word_flags=() + local_nonpersistent_flags=() + flags_with_completion=() + flags_completion=() + + + must_have_one_flag=() + must_have_one_noun=() + noun_aliases=() +} + _git-bug_commands() { last_command="git-bug_commands" @@ -704,6 +745,7 @@ _git-bug_root_command() commands=() commands+=("add") + commands+=("bridge") commands+=("commands") commands+=("comment") commands+=("label") diff --git a/misc/zsh_completion/git-bug b/misc/zsh_completion/git-bug index 077fa181..78f835ce 100644 --- a/misc/zsh_completion/git-bug +++ b/misc/zsh_completion/git-bug @@ -8,7 +8,7 @@ case $state in level1) case $words[1] in git-bug) - _arguments '1: :(add commands comment label ls ls-label pull push select show status termui title webui)' + _arguments '1: :(add bridge commands comment label ls ls-label pull push select show status termui title webui)' ;; *) _arguments '*: :_files' @@ -17,6 +17,9 @@ case $state in ;; level2) case $words[2] in + bridge) + _arguments '2: :(configure)' + ;; comment) _arguments '2: :(add)' ;; |