Skip to content

feat(cli): add --config flag to override config.ini location (#164)#165

Merged
nicolasbisurgi merged 1 commit into
masterfrom
feat/issue-164-config-flag
Jun 26, 2026
Merged

feat(cli): add --config flag to override config.ini location (#164)#165
nicolasbisurgi merged 1 commit into
masterfrom
feat/issue-164-config-flag

Conversation

@nicolasbisurgi

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional --config PATH flag (long-form only) to every TM1-connecting command — run, build, tasks …, resume — letting a single invocation point at an arbitrary config.ini (TM1 connection parameters). The driving use case: sharing one read-only config.ini with other tm1py utilities (e.g. OptimusPy) instead of duplicating credentials.

Closes #164.

Design (per ADR 0003)

  • Resolution precedence (highest wins): --config > RUSHTI_DIR > legacy CWD > config/.
  • Explicit threading, no global mutation. The resolved path flows as config_path into the TM1 connection layer (connect_to_tm1_instance, setup_tm1_services). The module-level CONFIG global in cli.py is demoted to the no-flag default (still computed at import for its legacy-path deprecation-warning side effect). The from rushti.cli import CONFIG fallback in execution.py is removed in favour of a required, explicit argument.
  • Relocates only config.inisettings.ini keeps --settings, logging_config.ini keeps its own resolution.
  • Fail fast on a bad path: exit 1, clean message, no traceback.
  • Not added to stats/db (no TM1 connection).
  • No behavioural change when the flag is absent — resolution is byte-for-byte today's behaviour.

Changes

Source

  • app_paths.py — shared add_config_arg(parser) helper (mirrors add_log_level_arg).
  • cli.py — flag on the run parser; config threaded into both cli_args dicts; resolve + fail-fast after parsing; fed into all three connect sites.
  • execution.py — removed the CONFIG import fallback; config_path now required.
  • commands/build.py, commands/resume.py (forwarded into the rebuilt argv), commands/tasks/__init__.py (all 5 subparsers + wired the existing stub).

Teststests/unit/test_config_flag.py (16 cases): helper parsing, run threading + fail-fast, build resolution + bad-path, all 5 tasks subcommands forwarding config_path, and resume surviving the argv rebuild.

Docs — README, CHANGELOG, CONTEXT.md, docs/advanced/cli-reference.md, docs/advanced/settings-reference.md.

Testing

  • Full unit suite: 788 passed, 5 skipped.
  • ruff + black clean (enforced by pre-commit).
  • Manual: verified --config appears on run/build/tasks/resume help, is absent on stats/db, -c still maps to resume --checkpoint, and a missing path exits 1 with a clean message.

🤖 Generated with Claude Code

Add an optional `--config PATH` flag (long-form only) to every
TM1-connecting command (run, build, tasks …, resume). It points a single
invocation at an arbitrary config.ini (TM1 connection parameters),
enabling a read-only config.ini shared with other tm1py utilities.

Resolution precedence (highest wins): --config > RUSHTI_DIR > legacy CWD
> config/. The resolved path is threaded explicitly as config_path into
the TM1 connection layer (connect_to_tm1_instance, setup_tm1_services)
rather than mutating the module-level CONFIG global, which is demoted to
the no-flag default. The execution.py `from rushti.cli import CONFIG`
fallback is removed in favour of a required, explicit argument.

--config relocates only config.ini; settings.ini keeps --settings and
logging_config.ini keeps its own resolution. A missing path fails fast
(exit 1, clean message, no traceback). Not added to stats/db, which open
no TM1 connection. No behavioural change when the flag is absent.

See docs/adr/0003-config-ini-location-resolution.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicolasbisurgi nicolasbisurgi self-assigned this Jun 26, 2026
@nicolasbisurgi nicolasbisurgi added the release:patch Triggers patch version bump (e.g.: 1.4.9 → 1.4.10) label Jun 26, 2026
@nicolasbisurgi nicolasbisurgi merged commit b9d4074 into master Jun 26, 2026
9 checks passed
@nicolasbisurgi nicolasbisurgi deleted the feat/issue-164-config-flag branch June 26, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:patch Triggers patch version bump (e.g.: 1.4.9 → 1.4.10)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --config flag to override config.ini location

1 participant