MCPcopy Index your code
hub / github.com/git-bug/git-bug / newBridgeAuthAddTokenCommand

Function newBridgeAuthAddTokenCommand

commands/bridge/bridge_auth_addtoken.go:27–53  ·  view source on GitHub ↗
(env *execenv.Env)

Source from the content-addressed store, hash-verified

25}
26
27func 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
55func runBridgeAuthAddToken(env *execenv.Env, opts bridgeAuthAddTokenOptions, args []string) error {
56 // Note: as bridgeAuthAddTokenLogin is not checked against the remote bug-tracker,

Callers 1

newBridgeAuthCommandFunction · 0.85

Calls 6

LoadBackendEnsureUserFunction · 0.92
CloseBackendFunction · 0.92
TargetsFunction · 0.92
FromFunction · 0.92
UserFunction · 0.92
runBridgeAuthAddTokenFunction · 0.85

Tested by

no test coverage detected