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)
| 56 | // |
| 57 | // ``` |
| 58 | func (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 | } |