-
Notifications
You must be signed in to change notification settings - Fork 361
/
login.go
42 lines (33 loc) · 1.13 KB
/
login.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package cmd
import (
"github.com/spf13/cobra"
"github.com/stripe/stripe-cli/pkg/login"
"github.com/stripe/stripe-cli/pkg/stripe"
"github.com/stripe/stripe-cli/pkg/validators"
)
type loginCmd struct {
cmd *cobra.Command
interactive bool
dashboardBaseURL string
}
func newLoginCmd() *loginCmd {
lc := &loginCmd{}
lc.cmd = &cobra.Command{
Use: "login",
Args: validators.NoArgs,
Short: "Login to your Stripe account",
Long: `Login to your Stripe account to setup the CLI`,
RunE: lc.runLoginCmd,
}
lc.cmd.Flags().BoolVarP(&lc.interactive, "interactive", "i", false, "Run interactive configuration mode if you cannot open a browser")
// Hidden configuration flags, useful for dev/debugging
lc.cmd.Flags().StringVar(&lc.dashboardBaseURL, "dashboard-base", stripe.DefaultDashboardBaseURL, "Sets the dashboard base URL")
lc.cmd.Flags().MarkHidden("dashboard-base") // #nosec G104
return lc
}
func (lc *loginCmd) runLoginCmd(cmd *cobra.Command, args []string) error {
if lc.interactive {
return login.InteractiveLogin(cmd.Context(), &Config)
}
return login.Login(cmd.Context(), lc.dashboardBaseURL, &Config)
}