(app *App)
| 17 | } |
| 18 | |
| 19 | func newStopCmd(app *App) *cobra.Command { |
| 20 | opts := &stopOptions{} |
| 21 | |
| 22 | stopCmd := &cobra.Command{ |
| 23 | Use: "stop", |
| 24 | Short: "Stop a running codespace", |
| 25 | Args: noArgsConstraint, |
| 26 | RunE: func(cmd *cobra.Command, args []string) error { |
| 27 | if opts.orgName != "" && opts.selector.codespaceName != "" && opts.userName == "" { |
| 28 | return cmdutil.FlagErrorf("using `--org` with `--codespace` requires `--user`") |
| 29 | } |
| 30 | return app.StopCodespace(cmd.Context(), opts) |
| 31 | }, |
| 32 | } |
| 33 | opts.selector = AddCodespaceSelector(stopCmd, app.apiClient) |
| 34 | stopCmd.Flags().StringVarP(&opts.orgName, "org", "o", "", "The `login` handle of the organization (admin-only)") |
| 35 | stopCmd.Flags().StringVarP(&opts.userName, "user", "u", "", "The `username` to stop codespace for (used with --org)") |
| 36 | |
| 37 | return stopCmd |
| 38 | } |
| 39 | |
| 40 | func (a *App) StopCodespace(ctx context.Context, opts *stopOptions) error { |
| 41 | var ( |
no test coverage detected