()
| 45 | ) |
| 46 | |
| 47 | func newCmdLogin() *cobra.Command { |
| 48 | loginCmd := &cobra.Command{ |
| 49 | Use: "login", |
| 50 | Short: loginShort, |
| 51 | Long: loginLong, |
| 52 | Example: loginExample, |
| 53 | Args: cobra.MatchAll(cobra.ExactArgs(0), cobra.OnlyValidArgs), |
| 54 | RunE: func(cmd *cobra.Command, args []string) error { |
| 55 | // Set up a channel to listen for OS signals for graceful shutdown. |
| 56 | ctx, cancel := context.WithCancel(cmd.Context()) |
| 57 | |
| 58 | sigChan := make(chan os.Signal, 1) |
| 59 | signal.Notify(sigChan, syscall.SIGTERM) |
| 60 | |
| 61 | go func() { |
| 62 | <-sigChan |
| 63 | cancel() |
| 64 | }() |
| 65 | |
| 66 | return runLogin(ctx, cmd) |
| 67 | }, |
| 68 | } |
| 69 | loginCmd.Flags().StringP("team", "t", "", "Team to login to. Specify the team name, e.g. 'my-team' (not the display name)") |
| 70 | return loginCmd |
| 71 | } |
| 72 | |
| 73 | func waitForServer(ctx context.Context, url string) error { |
| 74 | ctx, cancel := context.WithTimeout(ctx, 3*time.Second) |
no test coverage detected