diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-05-24 21:03:31 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-05-29 22:58:01 +0200 |
commit | f124df7e73f8613bf9cd2f83177eeb4110c7a639 (patch) | |
tree | 6dbe45269279dbac92c12332e0049da9c47849a3 /commands/bridge_configure.go | |
parent | 8bfc65df6c4db01e74e5793fb4da402078b37648 (diff) | |
download | git-bug-f124df7e73f8613bf9cd2f83177eeb4110c7a639.tar.gz |
changes to the BridgeImpl Interface
Add bridge params
Change bridge.Configure signature
Diffstat (limited to 'commands/bridge_configure.go')
-rw-r--r-- | commands/bridge_configure.go | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go index ce10d9af..b20b38a5 100644 --- a/commands/bridge_configure.go +++ b/commands/bridge_configure.go @@ -7,12 +7,24 @@ import ( "strconv" "strings" + "github.com/MichaelMure/git-bug/bridge/core" + "github.com/MichaelMure/git-bug/bridge" "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/util/interrupt" "github.com/spf13/cobra" ) +const ( + defaultName = "default" +) + +var ( + name string + target string + bridgeParams core.BridgeParams +) + func runBridgeConfigure(cmd *cobra.Command, args []string) error { backend, err := cache.NewRepoCache(repo) if err != nil { @@ -21,14 +33,18 @@ func runBridgeConfigure(cmd *cobra.Command, args []string) error { defer backend.Close() interrupt.RegisterCleaner(backend.Close) - target, err := promptTarget() - if err != nil { - return err + if target == "" { + target, err = promptTarget() + if err != nil { + return err + } } - name, err := promptName() - if err != nil { - return err + if name == "" { + name, err = promptName() + if err != nil { + return err + } } b, err := bridge.NewBridge(backend, target, name) @@ -36,11 +52,12 @@ func runBridgeConfigure(cmd *cobra.Command, args []string) error { return err } - err = b.Configure() + err = b.Configure(bridgeParams) if err != nil { return err } + fmt.Println("successfully configured bridge") return nil } @@ -71,8 +88,6 @@ func promptTarget() (string, error) { } func promptName() (string, error) { - defaultName := "default" - fmt.Printf("name [%s]: ", defaultName) line, err := bufio.NewReader(os.Stdin).ReadString('\n') @@ -98,4 +113,10 @@ var bridgeConfigureCmd = &cobra.Command{ func init() { bridgeCmd.AddCommand(bridgeConfigureCmd) + bridgeConfigureCmd.Flags().StringVarP(&name, "name", "n", "", "Bridge name") + bridgeConfigureCmd.Flags().StringVarP(&target, "target", "t", "", "Bridge target name. Valid values are [github,gitlab,gitea,launchpad]") + bridgeConfigureCmd.Flags().StringVarP(&bridgeParams.URL, "url", "u", "", "Repository url") + bridgeConfigureCmd.Flags().StringVarP(&bridgeParams.Owner, "owner", "o", "", "Repository owner") + bridgeConfigureCmd.Flags().StringVarP(&bridgeParams.Token, "token", "T", "", "Authentication token") + bridgeConfigureCmd.Flags().StringVarP(&bridgeParams.Project, "project", "p", "", "Repository name") } |