MCPcopy
hub / github.com/cli/cli / Select

Method Select

pkg/cmd/codespace/codespace_selector.go:37–63  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

35}
36
37func (cs *CodespaceSelector) Select(ctx context.Context) (codespace *api.Codespace, err error) {
38 if cs.codespaceName != "" {
39 codespace, err = cs.api.GetCodespace(ctx, cs.codespaceName, true)
40 if err != nil {
41 return nil, fmt.Errorf("getting full codespace details: %w", err)
42 }
43 } else {
44 codespaces, err := cs.fetchCodespaces(ctx)
45 if err != nil {
46 return nil, err
47 }
48
49 codespace, err = cs.chooseCodespace(ctx, codespaces)
50 if err != nil {
51 return nil, err
52 }
53 }
54
55 if codespace.PendingOperation {
56 return nil, fmt.Errorf(
57 "codespace is disabled while it has a pending operation: %s",
58 codespace.PendingOperationDisabledReason,
59 )
60 }
61
62 return codespace, nil
63}
64
65func (cs *CodespaceSelector) SelectName(ctx context.Context) (string, error) {
66 if cs.codespaceName != "" {

Callers 1

Calls 4

fetchCodespacesMethod · 0.95
chooseCodespaceMethod · 0.95
GetCodespaceMethod · 0.65
ErrorfMethod · 0.65

Tested by 1