MCPcopy Create free account
hub / github.com/compozy/agh / resolveWorkspaceInfoRef

Function resolveWorkspaceInfoRef

internal/cli/workspace.go:167–193  ·  view source on GitHub ↗
(deps commandDeps, args []string, workspaceFlag string)

Source from the content-addressed store, hash-verified

165}
166
167func resolveWorkspaceInfoRef(deps commandDeps, args []string, workspaceFlag string) (workspaceInfoRef, error) {
168 if len(args) > 0 {
169 ref := strings.TrimSpace(args[0])
170 if ref == "" {
171 return workspaceInfoRef{}, errors.New("cli: workspace reference is required")
172 }
173 return workspaceInfoRef{Ref: ref, Source: "positional"}, nil
174 }
175 if trimmed := strings.TrimSpace(workspaceFlag); trimmed != "" {
176 if isPathLikeWorkspaceRef(trimmed) {
177 resolved, err := aghconfig.ResolvePath(trimmed)
178 if err != nil {
179 return workspaceInfoRef{}, err
180 }
181 return workspaceInfoRef{Ref: resolved, Source: workspaceFlagKey}, nil
182 }
183 return workspaceInfoRef{Ref: trimmed, Source: workspaceFlagKey}, nil
184 }
185 if trimmed := strings.TrimSpace(deps.getenv("AGH_WORKSPACE")); trimmed != "" {
186 return workspaceInfoRef{Ref: trimmed, Source: configEnvKey}, nil
187 }
188 cwd, err := currentWorkingDirectory(deps)
189 if err != nil {
190 return workspaceInfoRef{}, err
191 }
192 return workspaceInfoRef{Ref: cwd, Source: "cwd"}, nil
193}
194
195func resolveCLIWorkspaceRouteRef(
196 ctx context.Context,

Callers 1

newWorkspaceInfoCommandFunction · 0.85

Calls 3

currentWorkingDirectoryFunction · 0.85
isPathLikeWorkspaceRefFunction · 0.70
ResolvePathMethod · 0.65

Tested by

no test coverage detected