feat(cli): add --config flag to override config.ini location (#164)#165
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
--config PATHflag (long-form only) to every TM1-connecting command —run,build,tasks …,resume— letting a single invocation point at an arbitraryconfig.ini(TM1 connection parameters). The driving use case: sharing one read-onlyconfig.iniwith other tm1py utilities (e.g. OptimusPy) instead of duplicating credentials.Closes #164.
Design (per ADR 0003)
--config>RUSHTI_DIR> legacy CWD >config/.config_pathinto the TM1 connection layer (connect_to_tm1_instance,setup_tm1_services). The module-levelCONFIGglobal incli.pyis demoted to the no-flag default (still computed at import for its legacy-path deprecation-warning side effect). Thefrom rushti.cli import CONFIGfallback inexecution.pyis removed in favour of a required, explicit argument.config.ini—settings.inikeeps--settings,logging_config.inikeeps its own resolution.stats/db(no TM1 connection).Changes
Source
app_paths.py— sharedadd_config_arg(parser)helper (mirrorsadd_log_level_arg).cli.py— flag on the run parser;configthreaded into both cli_args dicts; resolve + fail-fast after parsing; fed into all three connect sites.execution.py— removed theCONFIGimport fallback;config_pathnow required.commands/build.py,commands/resume.py(forwarded into the rebuilt argv),commands/tasks/__init__.py(all 5 subparsers + wired the existing stub).Tests —
tests/unit/test_config_flag.py(16 cases): helper parsing, run threading + fail-fast, build resolution + bad-path, all 5 tasks subcommands forwardingconfig_path, and resume surviving the argv rebuild.Docs — README, CHANGELOG, CONTEXT.md,
docs/advanced/cli-reference.md,docs/advanced/settings-reference.md.Testing
ruff+blackclean (enforced by pre-commit).--configappears on run/build/tasks/resume help, is absent on stats/db,-cstill maps toresume --checkpoint, and a missing path exits 1 with a clean message.🤖 Generated with Claude Code