fix: IMP-4/5/6 — parser allowlist, delete ID resolution, consistent errors
IMP-5: Replace strings.Contains(arg, ":") heuristic with an allowlist of recognized attribute keys (ValidAttributeKeys). Colons in task descriptions (URLs, "Meeting: topic") are no longer misinterpreted as modifiers. Canonical key sets live in engine/keys.go and are shared across parseAddArgs, ParseFilter, and ParseModifier. ParseModifier now errors on unknown keys. IMP-4: delete command now loads the working set and resolves display IDs via GetTaskByDisplayID, matching the pattern used by done/modify. IMP-6: All action commands (done, delete, modify, start, stop) now return an error on no-match (stderr, exit 1). Previously done/delete printed to stdout and exited 0; start/stop had no check at all. Also adds requirements and design docs for the CLI UX improvements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+16
-10
@@ -71,23 +71,29 @@ func addTask(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseAddArgs extracts description and modifiers from args
|
||||
// Description = all non-filter/modifier words joined with spaces
|
||||
// Filters/Modifiers = args with +, -, or containing :
|
||||
// parseAddArgs extracts description and modifiers from args.
|
||||
// Tags (+tag, -tag) are always modifiers. For key:value tokens, only
|
||||
// recognized attribute keys (engine.ValidAttributeKeys) are treated as
|
||||
// modifiers — everything else becomes part of the description.
|
||||
func parseAddArgs(args []string) (string, []string, error) {
|
||||
var descParts []string
|
||||
var modifiers []string
|
||||
|
||||
for _, arg := range args {
|
||||
isFilterOrModifier := strings.HasPrefix(arg, "+") ||
|
||||
strings.HasPrefix(arg, "-") ||
|
||||
strings.Contains(arg, ":")
|
||||
|
||||
if isFilterOrModifier {
|
||||
if strings.HasPrefix(arg, "+") || strings.HasPrefix(arg, "-") {
|
||||
modifiers = append(modifiers, arg)
|
||||
} else {
|
||||
descParts = append(descParts, arg)
|
||||
continue
|
||||
}
|
||||
|
||||
if idx := strings.Index(arg, ":"); idx > 0 {
|
||||
key := arg[:idx]
|
||||
if engine.ValidAttributeKeys[key] {
|
||||
modifiers = append(modifiers, arg)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
descParts = append(descParts, arg)
|
||||
}
|
||||
|
||||
if len(descParts) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user