aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-09-02 09:24:53 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-09-02 09:44:00 +0200
commitf3d8da10750d58fce482042cff87455a1e6f36e0 (patch)
tree5018a7356afa8ade6a69eb8767aa7a3439aa01da /commands
parent46f957344499863c97a20d34cf8ba078d3245c3a (diff)
downloadgit-bug-f3d8da10750d58fce482042cff87455a1e6f36e0.tar.gz
bridge/core: add tokenStdin field to bridgeParams
commands: move tokenStdin handling logic to bridge.Configure
Diffstat (limited to 'commands')
-rw-r--r--commands/bridge_configure.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go
index bb32c84e..12cc35e3 100644
--- a/commands/bridge_configure.go
+++ b/commands/bridge_configure.go
@@ -21,7 +21,6 @@ const (
)
var (
- tokenStdin bool
bridgeConfigureName string
bridgeConfigureTarget string
bridgeParams core.BridgeParams
@@ -35,8 +34,8 @@ func runBridgeConfigure(cmd *cobra.Command, args []string) error {
defer backend.Close()
interrupt.RegisterCleaner(backend.Close)
- if (tokenStdin || bridgeParams.Token != "") && (bridgeConfigureName == "" || bridgeConfigureTarget == "") {
- return fmt.Errorf("you must bridge name and target to configure a bridge with a token")
+ if (bridgeParams.TokenStdin || bridgeParams.Token != "") && (bridgeConfigureName == "" || bridgeConfigureTarget == "") {
+ return fmt.Errorf("you must provide a bridge name and target to configure a bridge with a token")
}
if bridgeConfigureTarget == "" {
@@ -58,15 +57,6 @@ func runBridgeConfigure(cmd *cobra.Command, args []string) error {
return err
}
- if tokenStdin {
- reader := bufio.NewReader(os.Stdin)
- token, err := reader.ReadString('\n')
- if err != nil {
- return fmt.Errorf("reading from stdin: %v", err)
- }
- bridgeParams.Token = strings.TrimSuffix(token, "\n")
- }
-
err = b.Configure(bridgeParams)
if err != nil {
return err
@@ -195,7 +185,7 @@ func init() {
bridgeConfigureCmd.Flags().StringVarP(&bridgeParams.URL, "url", "u", "", "The URL of the target repository")
bridgeConfigureCmd.Flags().StringVarP(&bridgeParams.Owner, "owner", "o", "", "The owner of the target repository")
bridgeConfigureCmd.Flags().StringVarP(&bridgeParams.Token, "token", "T", "", "The authentication token for the API")
- bridgeConfigureCmd.Flags().BoolVar(&tokenStdin, "token-stdin", false, "Will read the token from stdin and ignore --token")
+ bridgeConfigureCmd.Flags().BoolVar(&bridgeParams.TokenStdin, "token-stdin", false, "Will read the token from stdin and ignore --token")
bridgeConfigureCmd.Flags().StringVarP(&bridgeParams.Project, "project", "p", "", "The name of the target repository")
bridgeConfigureCmd.Flags().SortFlags = false
}