[PR #198] [MERGED] [cli] Add --config to point at a config file #197

Closed
opened 2026-10-13 19:48:43 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/198
Author: @Glitchy-Sheep
Created: 9/21/2026
Status: ✅ Merged
Merged: 9/21/2026
Merged by: @Glitchy-Sheep

Base: main ← Head: feat/config-path-flag


📝 Commits (3)

  • 56c16e5 [config] Take the config path as a parameter
  • d35a9b1 [cli] Add --config to point at a config file
  • f8fdc8b [docs] Describe --config and BOOSTY_DOWNLOADER_CONFIG

📊 Changes

10 files changed (+290 additions, -84 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 boosty_downloader/cli/cli_options.py (+28 -0)
📝 boosty_downloader/cli/commands/check.py (+14 -9)
📝 boosty_downloader/cli/commands/clean_cache.py (+11 -5)
📝 boosty_downloader/cli/commands/download.py (+14 -9)
📝 boosty_downloader/cli/composition_root.py (+7 -3)
📝 boosty_downloader/infrastructure/yaml_configuration/config.py (+53 -26)
📝 boosty_downloader/main.py (+9 -2)
📝 test/unit/cli/cli_smoke_test.py (+99 -4)
📝 test/unit/configuration/init_config_test.py (+51 -26)

📄 Description

📝 Summary

The config file can now be chosen. Before, it could only be config.yaml in the folder the app runs from.

🔧 What changes

  • boosty-downloader --config PATH <command> reads that file. BOOSTY_DOWNLOADER_CONFIG does the same for every command in a shell; the flag wins when both are given.
  • Without either, nothing changes: config.yaml next to the working directory, the sample created there on the first run, the same messages.
  • A missing file at the given path gets the sample there, like the default location. A missing folder is a plain error, not a traceback.
  • Error messages name the chosen file; the sample is written as UTF-8.

🧩 How

init_config(config_path) and load_settings(..., config_path) take the path. pydantic-settings binds the yaml file to the settings class, so _read_config builds a subclass per path. The app callback puts the path into ctx.obj as GlobalOptions; the three commands take ctx: typer.Context and pass it on. No module state.

check.py and clean_cache.py import typer at runtime now: typer resolves the Context annotation when it registers the command.

🚫 Not changed on purpose

  • No move of the default to a per-user folder (platformdirs): nobody asked for it, and the current default works for the common one-folder setup.
  • Relative paths inside the config (target_directory: ./boosty-downloads) are still resolved from the working directory, not from the config's folder.

🧪 Tests

  • Config loader: broken files stay untouched at a given path, the sample is created at the given path, a missing folder exits cleanly, the default is still the working directory, the given file wins over a config.yaml in the cwd.
  • CLI smoke: --config with a file in another folder (no sample in the cwd), the env var, the flag over the env var, the sample at the flag path, the root help names the env var.
  • task ci green locally: ruff, pyright strict, import-linter, 315 tests + e2e.
  • Live from an empty folder: --config to a real config runs check; without the flag a sample appears there as before; the env var works; --config /nope/x.yaml gives one clear error line.

✅ Checklist

  • Tested live on a real blog (feature or fix)
  • Updated CLI --help and README if needed
  • Updated docs/ if the download flow or dev process changed
  • Added a line to ## Unreleased in CHANGELOG.md (or the ci/skip-changelog label if not user-facing)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Glitchy-Sheep/boosty-downloader/pull/198 **Author:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Created:** 9/21/2026 **Status:** ✅ Merged **Merged:** 9/21/2026 **Merged by:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Base:** `main` ← **Head:** `feat/config-path-flag` --- ### 📝 Commits (3) - [`56c16e5`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/56c16e58b6d7ae26d6444df21ffa33cfacbf362f) [config] Take the config path as a parameter - [`d35a9b1`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/d35a9b1029684ea78a86c993d6c2fb42060b2f4f) [cli] Add --config to point at a config file - [`f8fdc8b`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/f8fdc8b6cd4449f858afbbe6a5167067a35b2d73) [docs] Describe --config and BOOSTY_DOWNLOADER_CONFIG ### 📊 Changes **10 files changed** (+290 additions, -84 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `boosty_downloader/cli/cli_options.py` (+28 -0) 📝 `boosty_downloader/cli/commands/check.py` (+14 -9) 📝 `boosty_downloader/cli/commands/clean_cache.py` (+11 -5) 📝 `boosty_downloader/cli/commands/download.py` (+14 -9) 📝 `boosty_downloader/cli/composition_root.py` (+7 -3) 📝 `boosty_downloader/infrastructure/yaml_configuration/config.py` (+53 -26) 📝 `boosty_downloader/main.py` (+9 -2) 📝 `test/unit/cli/cli_smoke_test.py` (+99 -4) 📝 `test/unit/configuration/init_config_test.py` (+51 -26) </details> ### 📄 Description ## 📝 Summary The config file can now be chosen. Before, it could only be `config.yaml` in the folder the app runs from. ## 🔧 What changes - `boosty-downloader --config PATH <command>` reads that file. `BOOSTY_DOWNLOADER_CONFIG` does the same for every command in a shell; the flag wins when both are given. - Without either, nothing changes: `config.yaml` next to the working directory, the sample created there on the first run, the same messages. - A missing file at the given path gets the sample there, like the default location. A missing folder is a plain error, not a traceback. - Error messages name the chosen file; the sample is written as UTF-8. ## 🧩 How `init_config(config_path)` and `load_settings(..., config_path)` take the path. pydantic-settings binds the yaml file to the settings class, so `_read_config` builds a subclass per path. The app callback puts the path into `ctx.obj` as `GlobalOptions`; the three commands take `ctx: typer.Context` and pass it on. No module state. `check.py` and `clean_cache.py` import `typer` at runtime now: typer resolves the `Context` annotation when it registers the command. ## 🚫 Not changed on purpose - No move of the default to a per-user folder (`platformdirs`): nobody asked for it, and the current default works for the common one-folder setup. - Relative paths inside the config (`target_directory: ./boosty-downloads`) are still resolved from the working directory, not from the config's folder. ## 🧪 Tests - Config loader: broken files stay untouched at a given path, the sample is created at the given path, a missing folder exits cleanly, the default is still the working directory, the given file wins over a `config.yaml` in the cwd. - CLI smoke: `--config` with a file in another folder (no sample in the cwd), the env var, the flag over the env var, the sample at the flag path, the root help names the env var. - `task ci` green locally: ruff, pyright strict, import-linter, 315 tests + e2e. - Live from an empty folder: `--config` to a real config runs `check`; without the flag a sample appears there as before; the env var works; `--config /nope/x.yaml` gives one clear error line. ## ✅ Checklist - [x] Tested live on a real blog (feature or fix) - [ ] Updated CLI `--help` and README if needed - [x] Updated `docs/` if the download flow or dev process changed - [x] Added a line to `## Unreleased` in CHANGELOG.md (or the `ci/skip-changelog` label if not user-facing) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 19:48:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Glitchy-Sheep/boosty-downloader#197
No description provided.