diff --git a/task.py b/task.py index 53cc8ed..4b97d16 100644 --- a/task.py +++ b/task.py @@ -10,10 +10,28 @@ from commands.done import mark_done +DEFAULT_CONFIG = """# Default configuration for task CLI +storage: + format: json + max_tasks: 1000 + +display: + color: true + unicode: true +""" + + def load_config(): - """Load configuration from file.""" - config_path = Path.home() / ".config" / "task-cli" / "config.yaml" - # NOTE: This will crash if config doesn't exist - known bug for bounty testing + """Load configuration from file, creating default if missing.""" + config_dir = Path.home() / ".config" / "task-cli" + config_path = config_dir / "config.yaml" + + if not config_path.exists(): + config_dir.mkdir(parents=True, exist_ok=True) + with open(config_path, "w") as f: + f.write(DEFAULT_CONFIG) + print(f"[task-cli] Created default config at {config_path}") + with open(config_path) as f: return f.read()