feat(config): add XDG path resolution with CWD fallback
Add _resolve_config_file() searching ~/.config/librofm-downloader/ then CWD. Wire into load_config() so None triggers search. Missing config.yaml is non-fatal (prints notice, uses defaults); missing secrets.yaml raises ConfigError listing searched paths. All OS exceptions wrapped as domain errors. XDG dir auto-created. Closes #22
This commit is contained in:
1 parent
090132f39e
commit
3ba9f25903
6 files changed
+308
-14
No files matched your search
@@ -15,8 +15,8 @@ console = Console()
|
||||
|
||||
|
||||
def run(
|
||||
config_path: str = "config.yaml",
|
||||
secrets_path: str = "secrets.yaml",
|
||||
config_path: str | None = None,
|
||||
secrets_path: str | None = None,
|
||||
history_path: str = "download_history.json",
|
||||
verbose: bool = False,
|
||||
limit: int = 0,
|
||||
@@ -43,6 +43,8 @@ def run(
|
||||
# 1. Load config
|
||||
try:
|
||||
config = load_config(config_path, secrets_path)
|
||||
if config._config_path is None:
|
||||
console.print("[yellow]config.yaml not found. Using built-in defaults.[/yellow]")
|
||||
except ConfigError as exc:
|
||||
console.print(f"[red]Config error:[/red] {exc}")
|
||||
return 1
|
||||
@@ -188,8 +190,8 @@ if __name__ == "__main__":
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="Download audiobooks from Libro.fm")
|
||||
parser.add_argument("--config", default="config.yaml", help="Path to config.yaml")
|
||||
parser.add_argument("--secrets", default="secrets.yaml", help="Path to secrets.yaml")
|
||||
parser.add_argument("--config", default=None, help="Path to config.yaml (default: search XDG then CWD)")
|
||||
parser.add_argument("--secrets", default=None, help="Path to secrets.yaml (default: search XDG then CWD)")
|
||||
parser.add_argument("--history", default="download_history.json", help="Path to download history JSON")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose output (URLs, sizes, tracebacks)")
|
||||
parser.add_argument(
|
||||
|
||||
Reference in new issue
Block a user