fix: migliora parsing comando /plan create per gestire nomi con spazi

- Aggiunto regex parsing per estrarre virgolette dalla stringa grezza
- Il comando ora funziona correttamente con nomi multi-parola
- Formato supportato: /plan create "Nome Piano" "Task1; Task2; Task3"
This commit is contained in:
opencode committed 2026-03-23 09:11:00 +01:00
1 parent 56f2819a92
commit d055204067
1 file changed
+28 -15
+28 -15
View File
@@ -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 <name> <task1;task2;...>")
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 <nome> \"<task1; task2; ...>\"")
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 <nome> \"<task1; task2; ...>\"")
elif args[0] == 'list':
plan_list()
elif args[0] == 'progress' and len(args) > 1: