commands: add bridge configure --token-id flag

amine created

Change summary

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

Detailed changes

bridge/github/config.go 🔗

@@ -318,21 +318,6 @@ func promptTokenOptions(repo repository.RepoCommon, owner, project string) (*cor
 	}
 }
 
-func tokenAlreadyExist(repo repository.RepoCommon, id string) (bool, error) {
-	tokens, err := core.LoadTokens(repo)
-	if err != nil {
-		return false, err
-	}
-
-	for _, token := range tokens {
-		if token.Target == target && token.Value == id {
-			return true, nil
-		}
-	}
-
-	return false, nil
-}
-
 func promptToken() (string, error) {
 	fmt.Println("You can generate a new token by visiting https://github.com/settings/tokens.")
 	fmt.Println("Choose 'Generate new token' and set the necessary access scope for your repository.")

commands/bridge_configure.go 🔗

@@ -34,7 +34,8 @@ func runBridgeConfigure(cmd *cobra.Command, args []string) error {
 	defer backend.Close()
 	interrupt.RegisterCleaner(backend.Close)
 
-	if (bridgeParams.TokenStdin || bridgeParams.Token != "") && (bridgeConfigureName == "" || bridgeConfigureTarget == "") {
+	if (bridgeParams.TokenStdin || bridgeParams.Token != "" || bridgeParams.TokenId != "") &&
+		(bridgeConfigureName == "" || bridgeConfigureTarget == "") {
 		return fmt.Errorf("you must provide a bridge name and target to configure a bridge with a token")
 	}
 
@@ -195,6 +196,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().StringVarP(&bridgeParams.TokenId, "token-id", "i", "", "The authentication token identifier 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