MCPcopy Index your code
hub / github.com/cli/cli / Select

Method Select

pkg/cmd/codespace/select.go:58–83  ·  view source on GitHub ↗

Hidden codespace `select` command allows to reuse existing codespace selection dialog by external GH CLI extensions. By default output selected codespace name into `stdout`. Pass `--file`(`-f`) flag along with a file path to output selected codespace name into a file instead. ## Examples With `std

(ctx context.Context, opts selectOptions)

Source from the content-addressed store, hash-verified

56//
57// ```
58func (a *App) Select(ctx context.Context, opts selectOptions) (err error) {
59 codespace, err := opts.selector.Select(ctx)
60 if err != nil {
61 return err
62 }
63
64 if opts.filePath != "" {
65 f, err := os.Create(opts.filePath)
66 if err != nil {
67 return fmt.Errorf("failed to create output file: %w", err)
68 }
69
70 defer safeClose(f, &err)
71
72 _, err = f.WriteString(codespace.Name)
73 if err != nil {
74 return fmt.Errorf("failed to write codespace name to output file: %w", err)
75 }
76
77 return nil
78 }
79
80 fmt.Fprintln(a.io.Out, codespace.Name)
81
82 return nil
83}

Callers 1

TestApp_SelectFunction · 0.95

Calls 4

safeCloseFunction · 0.70
SelectMethod · 0.65
CreateMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestApp_SelectFunction · 0.76