Allow cancelling configuration

Amine and Michael Muré created

correct error message

Co-Authored-By: Michael Muré <batolettre@gmail.com>

Change summary

bridge/github/config.go      | 4 ++--
commands/bridge_configure.go | 7 +++++++
commands/bridge_rm.go        | 2 +-
3 files changed, 10 insertions(+), 3 deletions(-)

Detailed changes

bridge/github/config.go 🔗

@@ -98,7 +98,7 @@ func (*Github) Configure(repo repository.RepoCommon, params core.BridgeParams) (
 		return nil, err
 	}
 	if !ok {
-		return nil, fmt.Errorf("project doesn't exist or authentication token has a wrong scope")
+		return nil, fmt.Errorf("project doesn't exist or authentication token has an incorrect scope")
 	}
 
 	conf[keyToken] = token
@@ -428,7 +428,7 @@ func splitURL(url string) (owner string, project string, err error) {
 
 	owner = res[1]
 	project = res[2]
-	return owner, project, nil
+	return
 }
 
 func getValidGithubRemoteURLs(remotes map[string]string) []string {

commands/bridge_configure.go 🔗

@@ -33,6 +33,13 @@ 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
+	}
+	interrupt.RegisterCleaner(func() error {
+		return terminal.Restore(int(syscall.Stdin), termState)
+	})
 	if bridgeConfigureTarget == "" {
 		bridgeConfigureTarget, err = promptTarget()
 		if err != nil {

commands/bridge_rm.go 🔗

@@ -24,7 +24,7 @@ func runBridgeRm(cmd *cobra.Command, args []string) error {
 }
 
 var bridgeRmCmd = &cobra.Command{
-	Use:     "rm <name>",
+	Use:     "rm name <name>",
 	Short:   "Delete a configured bridge.",
 	PreRunE: loadRepo,
 	RunE:    runBridgeRm,