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

Function resolveTaskScopeWorkspace

internal/cli/task.go:2799–2824  ·  view source on GitHub ↗
(
	rawScope string,
	workspaceRef string,
	scopeRequired bool,
)

Source from the content-addressed store, hash-verified

2797}
2798
2799func resolveTaskScopeWorkspace(
2800 rawScope string,
2801 workspaceRef string,
2802 scopeRequired bool,
2803) (taskpkg.Scope, string, error) {
2804 scope, err := parseOptionalTaskScope(rawScope)
2805 if err != nil {
2806 return "", "", err
2807 }
2808 if scopeRequired && scope == "" {
2809 return "", "", errors.New("cli: --scope is required")
2810 }
2811
2812 workspace := strings.TrimSpace(workspaceRef)
2813 switch scope.Normalize() {
2814 case taskpkg.ScopeGlobal:
2815 if workspace != "" {
2816 return "", "", errors.New("cli: --workspace must be empty when --scope is global")
2817 }
2818 case taskpkg.ScopeWorkspace:
2819 if workspace == "" {
2820 return "", "", errors.New("cli: --workspace is required when --scope is workspace")
2821 }
2822 }
2823 return scope, workspace, nil
2824}
2825
2826func parseOptionalTaskScope(raw string) (taskpkg.Scope, error) {
2827 trimmed := strings.ToLower(strings.TrimSpace(raw))

Callers 2

parseTaskListFiltersFunction · 0.85
buildTaskCreateRequestFunction · 0.85

Calls 2

parseOptionalTaskScopeFunction · 0.85
NormalizeMethod · 0.45

Tested by

no test coverage detected