Edits a codespace
(ctx context.Context, opts editOptions)
| 45 | |
| 46 | // Edits a codespace |
| 47 | func (a *App) Edit(ctx context.Context, opts editOptions) error { |
| 48 | codespaceName, err := opts.selector.SelectName(ctx) |
| 49 | if err != nil { |
| 50 | // TODO: is there a cleaner way to do this? |
| 51 | if errors.Is(err, errNoCodespaces) || errors.Is(err, errNoFilteredCodespaces) { |
| 52 | return err |
| 53 | } |
| 54 | return fmt.Errorf("error choosing codespace: %w", err) |
| 55 | } |
| 56 | |
| 57 | err = a.RunWithProgress("Editing codespace", func() (err error) { |
| 58 | _, err = a.apiClient.EditCodespace(ctx, codespaceName, &api.EditCodespaceParams{ |
| 59 | DisplayName: opts.displayName, |
| 60 | Machine: opts.machine, |
| 61 | }) |
| 62 | return |
| 63 | }) |
| 64 | if err != nil { |
| 65 | return fmt.Errorf("error editing codespace: %w", err) |
| 66 | } |
| 67 | |
| 68 | return nil |
| 69 | } |