(deps commandDeps, args []string, workspaceFlag string)
| 165 | } |
| 166 | |
| 167 | func 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 | |
| 195 | func resolveCLIWorkspaceRouteRef( |
| 196 | ctx context.Context, |
no test coverage detected