Problem
When users run subcommands with trailing --dry-run (e.g. devops repos sync --dry-run or devops tf apply --dry-run), the top-level Click callback in main.py receives dry_run=False (since --dry-run occurred in the subcommand position) and executes set_dry_run(dry_run), overwriting the global dry-run state previously activated by entry.py. Furthermore, _lazy_proxy in src/devops_cli/core/cli.py only checks is_dry_run(), failing to detect --dry-run in ctx.args, and delegates the raw flag to target module apps where Click throws Error: No such option: --dry-run.
Proposed Solution
- In
src/devops_cli/main.py: Guard set_dry_run(True) so that main() never resets active dry-run state when dry_run is False.
- In
src/devops_cli/core/cli.py: Enhance _lazy_proxy to detect trailing --dry-run in ctx.args, strip it, set global dry-run state, and execute the simulated dry-run output cleanly.
- In
src/devops_cli/commands/repos.py: Expose explicit --dry-run option on sync / update so that directly invoked app instances also support --dry-run.
- Add comprehensive test coverage in
tests/test_all_commands_help_dryrun.py and tests/test_main_dry_run.py verifying leading and trailing --dry-run across subcommands.
Problem
When users run subcommands with trailing
--dry-run(e.g.devops repos sync --dry-runordevops tf apply --dry-run), the top-level Click callback inmain.pyreceivesdry_run=False(since--dry-runoccurred in the subcommand position) and executesset_dry_run(dry_run), overwriting the global dry-run state previously activated byentry.py. Furthermore,_lazy_proxyinsrc/devops_cli/core/cli.pyonly checksis_dry_run(), failing to detect--dry-runinctx.args, and delegates the raw flag to target module apps where Click throwsError: No such option: --dry-run.Proposed Solution
src/devops_cli/main.py: Guardset_dry_run(True)so thatmain()never resets active dry-run state whendry_runis False.src/devops_cli/core/cli.py: Enhance_lazy_proxyto detect trailing--dry-runinctx.args, strip it, set global dry-run state, and execute the simulated dry-run output cleanly.src/devops_cli/commands/repos.py: Expose explicit--dry-runoption onsync/updateso that directly invoked app instances also support--dry-run.tests/test_all_commands_help_dryrun.pyandtests/test_main_dry_run.pyverifying leading and trailing--dry-runacross subcommands.