Skip to content

✨ Configurable default language via env var and ~/.askcc/config.toml#93

Merged
monkut merged 2 commits into
mainfrom
feature/92-configurable-default-language
Apr 28, 2026
Merged

✨ Configurable default language via env var and ~/.askcc/config.toml#93
monkut merged 2 commits into
mainfrom
feature/92-configurable-default-language

Conversation

@monkut

@monkut monkut commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Closes #92

Summary

  • Default --language now resolves from CLI > env (ASKCC_LANGUAGE) > ~/.askcc/config.toml [defaults].language > built-in default (english). Invalid values warn and fall through; missing config files are silent.
  • Adds _load_user_config() (caches parsed ~/.askcc/config.toml at module import) and _resolve_default_language() in askcc/settings.py, mirroring the existing _resolve_effort_level() pattern.
  • Moves SupportedLanguage from askcc/definitions.py to askcc/settings.py to avoid a circular import (same constraint that already pinned VALID_EFFORT_LEVELS here). All known call sites updated.

Files touched

  • askcc/settings.pytomllib import, SupportedLanguage (moved here), USER_CONFIG_PATH, _load_user_config, _USER_CONFIG, _resolve_default_language, DEFAULT_LANGUAGE.
  • askcc/definitions.py — remove SupportedLanguage (now lives in settings.py).
  • askcc/cli.py — split SupportedLanguage import to .settings; switch argparse default to settings.DEFAULT_LANGUAGE; update help text.
  • tests/test_askcc.py — update SupportedLanguage import path; add TestDefaultLanguageResolution (11 tests).
  • README.md — document ASKCC_LANGUAGE and ~/.askcc/config.toml precedence.

Test plan

  • uv run pytest — 197 passed (11 new tests in TestDefaultLanguageResolution)
  • uv run ruff check — clean
  • uv run pyright — 0 errors

Risks / notes

  • SupportedLanguage import path change is internal-only (package marked Private :: Do Not Upload).
  • TOML parse-error log message intentionally omits the exception detail to avoid echoing config contents into logs.
  • Module-level _USER_CONFIG cache means refresh requires a fresh process; tests inject a dict via the optional user_config argument.

…(refs #92)

Resolve the default --language value from CLI > env (ASKCC_LANGUAGE) >
~/.askcc/config.toml [defaults].language > built-in default (english).
Invalid values warn and fall through. Missing config files are silent.

- Move SupportedLanguage enum from definitions.py to settings.py to break
  the import cycle with the new DEFAULT_LANGUAGE constant.
- Add _load_user_config() and _resolve_default_language() in settings.py.
- Wire DEFAULT_LANGUAGE into the argparse default in cli.py.
- Document ASKCC_LANGUAGE and the user config file in README.md.
@monkut monkut merged commit 9616bd7 into main Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: configurable default language via env var and ~/.askcc/config.toml

1 participant