package cmd import ( "fmt" "os" "github.com/warrenronsiek/ctask/internal/workspace" ) // resolveOne resolves a query to exactly one workspace. Prints errors and exits on 0 or >1 matches. func resolveOne(root, query string, includeArchived bool) *workspace.QueryResult { results, err := workspace.ResolveQuery(root, query, includeArchived) if err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } if len(results) == 0 { fmt.Fprintf(os.Stderr, "No workspace matches %q.\n", query) os.Exit(1) } if len(results) > 1 { fmt.Fprintf(os.Stderr, "Multiple workspaces match %q:\n", query) for _, r := range results { fmt.Fprintf(os.Stderr, " %s\n", workspace.RelativePath(root, r.Path)) } fmt.Fprintln(os.Stderr, "Specify a more precise query.") os.Exit(1) } return &results[0] }