MCPcopy
hub / github.com/cli/cli / Edit

Method Edit

pkg/cmd/codespace/edit.go:47–69  ·  view source on GitHub ↗

Edits a codespace

(ctx context.Context, opts editOptions)

Source from the content-addressed store, hash-verified

45
46// Edits a codespace
47func (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}

Callers 1

TestEditFunction · 0.95

Calls 4

RunWithProgressMethod · 0.95
SelectNameMethod · 0.80
ErrorfMethod · 0.65
EditCodespaceMethod · 0.65

Tested by 1

TestEditFunction · 0.76