diff options
author | Michael Muré <batolettre@gmail.com> | 2019-09-02 11:34:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-02 11:34:47 +0200 |
commit | 16af70894c0348ec90dfee69274f7d44ef2eb079 (patch) | |
tree | 5018a7356afa8ade6a69eb8767aa7a3439aa01da /commands/bridge_configure.go | |
parent | c7792a5d1279a92c8d0caf67a0cf688cc9e32e09 (diff) | |
parent | f3d8da10750d58fce482042cff87455a1e6f36e0 (diff) | |
download | git-bug-16af70894c0348ec90dfee69274f7d44ef2eb079.tar.gz |
Merge pull request #200 from MichaelMure/bridge-token-stdin
bridge: support --token-stdin
Diffstat (limited to 'commands/bridge_configure.go')
-rw-r--r-- | commands/bridge_configure.go | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go index 6bebc262..12cc35e3 100644 --- a/commands/bridge_configure.go +++ b/commands/bridge_configure.go @@ -6,10 +6,8 @@ import ( "os" "strconv" "strings" - "syscall" "github.com/spf13/cobra" - "golang.org/x/crypto/ssh/terminal" "github.com/MichaelMure/git-bug/bridge" "github.com/MichaelMure/git-bug/bridge/core" @@ -36,15 +34,10 @@ func runBridgeConfigure(cmd *cobra.Command, args []string) error { defer backend.Close() interrupt.RegisterCleaner(backend.Close) - termState, err := terminal.GetState(int(syscall.Stdin)) - if err != nil { - return err + 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") } - interrupt.RegisterCleaner(func() error { - return terminal.Restore(int(syscall.Stdin), termState) - }) - if bridgeConfigureTarget == "" { bridgeConfigureTarget, err = promptTarget() if err != nil { @@ -192,6 +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(&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 } |