feat(v0.3): add Projects filter to ListWorkspaces; fix last/delete
ListOpts gains a Projects bool that filters by EffectiveType. Default behavior (Projects: false) now returns tasks only -- this is a deliberate semantic change that supports the new 'ctask list' (tasks) vs 'ctask list --projects' (projects) spec. The change silently regresses two cmd-level callers that scan for "the most recently updated workspace": cmd/last.go (used by 'ctask last') and cmd/delete.go (used to print the "this was your most recent workspace" note). Both are fixed by unioning a tasks-scan with a projects-scan, so 'last' and 'delete' continue to consider both types. Test helper createTestWorkspaceTyped allows setting an explicit type (or "" to simulate a v0.2 workspace with no type field).
This commit is contained in:
+9
-2
@@ -70,11 +70,18 @@ func runDelete(cmd *cobra.Command, args []string) error {
|
||||
fmt.Printf(" Workspace: %s\n", relPath)
|
||||
fmt.Printf(" Files: %d (%s)\n", fileCount, formatSize(totalSize))
|
||||
|
||||
// Check if this is the most recently updated workspace
|
||||
results, _ := workspace.ListWorkspaces(root, workspace.ListOpts{
|
||||
// Check if this is the most recently updated workspace.
|
||||
// v0.3: union tasks and projects so the "most recent" check spans both types.
|
||||
tasks, _ := workspace.ListWorkspaces(root, workspace.ListOpts{
|
||||
IncludeArchived: false,
|
||||
Limit: 0,
|
||||
})
|
||||
projects, _ := workspace.ListWorkspaces(root, workspace.ListOpts{
|
||||
IncludeArchived: false,
|
||||
Projects: true,
|
||||
Limit: 0,
|
||||
})
|
||||
results := append(tasks, projects...)
|
||||
if len(results) > 0 {
|
||||
best := results[0]
|
||||
for _, r := range results[1:] {
|
||||
|
||||
+13
-2
@@ -31,14 +31,25 @@ func init() {
|
||||
func runLast(cmd *cobra.Command, args []string) error {
|
||||
root := config.ResolveRoot()
|
||||
|
||||
// Scan all non-archived workspaces and find the most recently updated
|
||||
results, err := workspace.ListWorkspaces(root, workspace.ListOpts{
|
||||
// Scan all non-archived workspaces (tasks AND projects) and find the most
|
||||
// recently updated. v0.3: ListWorkspaces filters by type, so we union the
|
||||
// two type buckets here so `last` keeps working for both.
|
||||
tasks, err := workspace.ListWorkspaces(root, workspace.ListOpts{
|
||||
IncludeArchived: false,
|
||||
Limit: 0,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
projects, err := workspace.ListWorkspaces(root, workspace.ListOpts{
|
||||
IncludeArchived: false,
|
||||
Projects: true,
|
||||
Limit: 0,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
results := append(tasks, projects...)
|
||||
|
||||
if len(results) == 0 {
|
||||
fmt.Fprintln(os.Stderr, "No active workspaces found.")
|
||||
|
||||
Reference in New Issue
Block a user