Slice 2: CLI wiring, messaging & history XDG default #23

Closed
opened 2026-06-04 09:29:43 +02:00 by AlexKucera · 1 comment
AlexKucera commented 2026-06-04 09:29:43 +02:00 (Migrated from github.com)

Parent

#21 — Feature: XDG config path resolution with CWD fallback

What to build

Wire the path resolver into the CLI layer so that running librofm-downloader with no flags finds config/secrets/history via XDG→CWD search. Change run() default parameters for config_path, secrets_path, and history_path from CWD strings ("config.yaml" etc.) to None (meaning "search"). When config is missing everywhere: always print a visible message like "config.yaml not found in <paths>. Using built-in defaults." — not silenced, not verbose-only. When secrets are missing everywhere: print fatal error listing all searched paths and exit 1.

Apply the same XDG→CWD resolution to the history file default. Explicit --config, --secrets, and --history CLI flags must bypass search entirely and use the provided path as-is (backward compatibility). In --verbose mode, print which path was resolved for each file.

Acceptance criteria

  • run() with no path args → searches XDG then CWD for all three files
  • Missing config → prints "using built-in defaults" message (always visible), continues execution
  • Missing secrets → prints error listing searched paths, exits 1 (no traceback)
  • History file defaults to ~/.config/librofm-downloader/download_history.json
  • Explicit --config ./foo.yaml skips search, uses exact path
  • --verbose shows resolved paths for config, secrets, and history
  • Running from empty home dir (no XDG, no CWD files) → clean secrets error, no Python traceback
  • Running with only secrets in XDG → works, uses all defaults, downloads succeed
  • All existing CLI tests pass unchanged
  • New tests: invoke run() with various filesystem layouts, capture console output, verify correct messages and exit codes

Blocked by

#22 — Slice 1: Path resolution engine & config loading

## Parent #21 — Feature: XDG config path resolution with CWD fallback ## What to build Wire the path resolver into the CLI layer so that running `librofm-downloader` with no flags finds config/secrets/history via XDG→CWD search. Change `run()` default parameters for `config_path`, `secrets_path`, and `history_path` from CWD strings (`"config.yaml"` etc.) to `None` (meaning "search"). When config is missing everywhere: always print a visible message like `"config.yaml not found in <paths>. Using built-in defaults."` — not silenced, not verbose-only. When secrets are missing everywhere: print fatal error listing all searched paths and exit 1. Apply the same XDG→CWD resolution to the history file default. Explicit `--config`, `--secrets`, and `--history` CLI flags must bypass search entirely and use the provided path as-is (backward compatibility). In `--verbose` mode, print which path was resolved for each file. ## Acceptance criteria - [ ] `run()` with no path args → searches XDG then CWD for all three files - [ ] Missing config → prints "using built-in defaults" message (always visible), continues execution - [ ] Missing secrets → prints error listing searched paths, exits 1 (no traceback) - [ ] History file defaults to `~/.config/librofm-downloader/download_history.json` - [ ] Explicit `--config ./foo.yaml` skips search, uses exact path - [ ] `--verbose` shows resolved paths for config, secrets, and history - [ ] Running from empty home dir (no XDG, no CWD files) → clean secrets error, no Python traceback - [ ] Running with only secrets in XDG → works, uses all defaults, downloads succeed - [ ] All existing CLI tests pass unchanged - [ ] New tests: invoke `run()` with various filesystem layouts, capture console output, verify correct messages and exit codes ## Blocked by #22 — Slice 1: Path resolution engine & config loading
AlexKucera commented 2026-06-04 10:32:58 +02:00 (Migrated from github.com)

Implemented in 01b14f1. All 10 AC met, 188/188 tests pass.

Implemented in 01b14f1. All 10 AC met, 188/188 tests pass.
Sign in to join this conversation.