diff --git a/main.py b/main.py index 5a4c31d..cc11930 100644 --- a/main.py +++ b/main.py @@ -890,27 +890,40 @@ def process_command(user_input: str) -> bool: if not args: print("❌ Specifica un sottocomando: create, list, progress, start, complete") elif args[0] == 'create': - # Handle plan creation with proper parsing + # Handle plan creation with special parsing for quoted strings # Format: /plan create "Plan Name" "Task 1; Task 2; Task 3" - # Or: /plan create PlanName Task1;Task2;Task3 - if len(args) < 3: - print("❌ Usage: /plan create ") - else: - # Find the first semicolon to split name from tasks - remaining = ' '.join(args[1:]) - - # Check if there's a semicolon to determine name/tasks split - if ';' in remaining: - # Find the first semicolon - semi_idx = remaining.index(';') - name = remaining[:semi_idx].strip() - tasks = remaining[semi_idx+1:].strip() + # Or: /plan create PlanName "Task1; Task2; Task3" + import re + # Get the raw part after "plan create" + raw_part = command_line[len("plan create "):] + + # Find all quoted strings (handles both " and ' quotes) + quoted_pattern = r'"([^"]*)"|\'([^\']*)\'' + matches = re.findall(quoted_pattern, raw_part) + + if len(matches) >= 2: + # Both name and tasks are quoted + name = matches[0][0] or matches[0][1] + tasks = matches[1][0] or matches[1][1] + plan_create(name, tasks) + elif len(matches) == 1: + # Only one quoted string - it's the tasks, name is the first unquoted word + tasks = matches[0][0] or matches[0][1] + # Find the name as the first word before the quoted part + unquoted_start = raw_part.find('"') if '"' in raw_part else raw_part.find("'") + name = raw_part[:unquoted_start].strip() + if name and tasks: plan_create(name, tasks) else: - # No semicolon found - use second arg as first task name, rest as description + print("❌ Usage: /plan create \"\"") + else: + # No quotes - use simple split + if len(args) >= 3: name = args[1] tasks = ' '.join(args[2:]) plan_create(name, tasks) + else: + print("❌ Usage: /plan create \"\"") elif args[0] == 'list': plan_list() elif args[0] == 'progress' and len(args) > 1: