summaryrefslogtreecommitdiff
path: root/internal/askcli/command_info_add.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/askcli/command_info_add.go')
-rw-r--r--internal/askcli/command_info_add.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/askcli/command_info_add.go b/internal/askcli/command_info_add.go
index 0de9be5..2680163 100644
--- a/internal/askcli/command_info_add.go
+++ b/internal/askcli/command_info_add.go
@@ -70,15 +70,22 @@ func extractUUIDFromAddOutput(output string) string {
return ""
}
+// parseAddArgs splits args into taskwarrior modifier tokens and the description.
+// Modifier tokens are args that start with "priority:", "+", or "-" AND contain
+// no spaces (tags and priority flags cannot have spaces). The first arg that is
+// not a modifier begins the description; all remaining args are joined with spaces.
+// If all args are modifiers the description is empty.
func parseAddArgs(args []string) (modifiers []string, description string) {
for i, arg := range args {
- if strings.HasPrefix(arg, "priority:") || strings.HasPrefix(arg, "+") || strings.HasPrefix(arg, "-") {
+ isModifier := !strings.Contains(arg, " ") &&
+ (strings.HasPrefix(arg, "priority:") || strings.HasPrefix(arg, "+") || strings.HasPrefix(arg, "-"))
+ if isModifier {
modifiers = append(modifiers, arg)
} else {
description = strings.Join(args[i:], " ")
return
}
}
- description = strings.Join(args, " ")
+ // All args were modifiers; no description provided.
return
}