MCPcopy
hub / github.com/cli/cli / newEditCmd

Function newEditCmd

pkg/cmd/codespace/edit.go:19–44  ·  view source on GitHub ↗
(app *App)

Source from the content-addressed store, hash-verified

17}
18
19func newEditCmd(app *App) *cobra.Command {
20 opts := editOptions{}
21
22 editCmd := &cobra.Command{
23 Use: "edit",
24 Short: "Edit a codespace",
25 Args: noArgsConstraint,
26 RunE: func(cmd *cobra.Command, args []string) error {
27 if opts.displayName == "" && opts.machine == "" {
28 return cmdutil.FlagErrorf("must provide `--display-name` or `--machine`")
29 }
30
31 return app.Edit(cmd.Context(), opts)
32 },
33 }
34
35 opts.selector = AddCodespaceSelector(editCmd, app.apiClient)
36 editCmd.Flags().StringVarP(&opts.displayName, "display-name", "d", "", "Set the display name")
37 editCmd.Flags().StringVar(&opts.displayName, "displayName", "", "Display name")
38 if err := editCmd.Flags().MarkDeprecated("displayName", "use `--display-name` instead"); err != nil {
39 fmt.Fprintf(app.io.ErrOut, "error marking flag as deprecated: %v\n", err)
40 }
41 editCmd.Flags().StringVarP(&opts.machine, "machine", "m", "", "Set hardware specifications for the VM")
42
43 return editCmd
44}
45
46// Edits a codespace
47func (a *App) Edit(ctx context.Context, opts editOptions) error {

Callers 2

TestEditFunction · 0.85
NewCmdCodespaceFunction · 0.85

Calls 3

FlagErrorfFunction · 0.92
AddCodespaceSelectorFunction · 0.85
EditMethod · 0.65

Tested by 1

TestEditFunction · 0.68