(env *execenv.Env)
| 25 | } |
| 26 | |
| 27 | func newBridgeAuthAddTokenCommand(env *execenv.Env) *cobra.Command { |
| 28 | options := bridgeAuthAddTokenOptions{} |
| 29 | |
| 30 | cmd := &cobra.Command{ |
| 31 | Use: "add-token [TOKEN]", |
| 32 | Short: "Store a new token", |
| 33 | PreRunE: execenv.LoadBackendEnsureUser(env), |
| 34 | RunE: execenv.CloseBackend(env, func(cmd *cobra.Command, args []string) error { |
| 35 | return runBridgeAuthAddToken(env, options, args) |
| 36 | }), |
| 37 | Args: cobra.MaximumNArgs(1), |
| 38 | } |
| 39 | |
| 40 | flags := cmd.Flags() |
| 41 | flags.SortFlags = false |
| 42 | |
| 43 | flags.StringVarP(&options.target, "target", "t", "", |
| 44 | fmt.Sprintf("The target of the bridge. Valid values are [%s]", strings.Join(bridge.Targets(), ","))) |
| 45 | cmd.RegisterFlagCompletionFunc("target", completion.From(bridge.Targets())) |
| 46 | flags.StringVarP(&options.login, |
| 47 | "login", "l", "", "The login in the remote bug-tracker") |
| 48 | flags.StringVarP(&options.user, |
| 49 | "user", "u", "", "The user to add the token to. Default is the current user") |
| 50 | cmd.RegisterFlagCompletionFunc("user", completion.User(env)) |
| 51 | |
| 52 | return cmd |
| 53 | } |
| 54 | |
| 55 | func runBridgeAuthAddToken(env *execenv.Env, opts bridgeAuthAddTokenOptions, args []string) error { |
| 56 | // Note: as bridgeAuthAddTokenLogin is not checked against the remote bug-tracker, |
no test coverage detected