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

Function resolveCLIWorkspaceRouteRef

internal/cli/workspace.go:195–224  ·  view source on GitHub ↗
(
	ctx context.Context,
	deps commandDeps,
	client DaemonClient,
	workspaceRef string,
)

Source from the content-addressed store, hash-verified

193}
194
195func resolveCLIWorkspaceRouteRef(
196 ctx context.Context,
197 deps commandDeps,
198 client DaemonClient,
199 workspaceRef string,
200) (string, error) {
201 trimmed := strings.TrimSpace(workspaceRef)
202 if trimmed == "" {
203 trimmed = strings.TrimSpace(deps.getenv("AGH_WORKSPACE"))
204 }
205 if trimmed == "" {
206 cwd, err := currentWorkingDirectory(deps)
207 if err != nil {
208 return "", err
209 }
210 trimmed = cwd
211 }
212 if !workspaceRefLooksLikePath(trimmed) {
213 return trimmed, nil
214 }
215 detail, err := client.GetWorkspace(ctx, trimmed)
216 if err != nil {
217 return "", fmt.Errorf("cli: resolve workspace %q: %w", trimmed, err)
218 }
219 workspaceID := strings.TrimSpace(detail.Workspace.ID)
220 if workspaceID == "" {
221 return "", fmt.Errorf("cli: resolve workspace %q: missing workspace id", trimmed)
222 }
223 return workspaceID, nil
224}
225
226func isPathLikeWorkspaceRef(ref string) bool {
227 return filepath.IsAbs(ref) ||

Callers 4

newLogsCommandFunction · 0.85
newHooksRunsCommandFunction · 0.85
newTaskPromoteCommandFunction · 0.85

Calls 3

currentWorkingDirectoryFunction · 0.85
GetWorkspaceMethod · 0.65

Tested by

no test coverage detected