aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bridge/github/config.go11
-rw-r--r--commands/bridge_configure.go4
2 files changed, 15 insertions, 0 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go
index 954bf845..d1b57e10 100644
--- a/bridge/github/config.go
+++ b/bridge/github/config.go
@@ -21,6 +21,7 @@ import (
"github.com/MichaelMure/git-bug/bridge/core"
"github.com/MichaelMure/git-bug/repository"
+ "github.com/MichaelMure/git-bug/util/interrupt"
)
const (
@@ -236,6 +237,16 @@ func promptTokenOptions(owner, project string) (string, error) {
return promptToken()
}
+ // Register restore state cleaner before prompting passwords inputs
+ termState, err := terminal.GetState(int(syscall.Stdin))
+ if err != nil {
+ return "", err
+ }
+
+ interrupt.RegisterCleaner(func() error {
+ return terminal.Restore(int(syscall.Stdin), termState)
+ })
+
return loginAndRequestToken(owner, project)
}
}
diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go
index 95cff1a2..bb32c84e 100644
--- a/commands/bridge_configure.go
+++ b/commands/bridge_configure.go
@@ -35,6 +35,10 @@ 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 bridgeConfigureTarget == "" {
bridgeConfigureTarget, err = promptTarget()
if err != nil {