From 7239088013aae27934e3b37b99fd2b0cf5be63d8 Mon Sep 17 00:00:00 2001 From: Jaixii Date: Mon, 29 Jun 2026 04:44:32 -0400 Subject: [PATCH 1/2] feat: add --require-license strict mode flag Closes #32 --- src/deploydiff/cli.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/deploydiff/cli.py b/src/deploydiff/cli.py index f84d6e1..7bd6767 100644 --- a/src/deploydiff/cli.py +++ b/src/deploydiff/cli.py @@ -26,13 +26,32 @@ @click.group() @click.version_option(package_name="deploydiff") @click.option("--no-gate", is_flag=True, help="Skip license gating check.") +@click.option( + "--require-license", + is_flag=True, + envvar="REVENUEHOLDINGS_REQUIRE_LICENSE", + help=( + "Exit with an error if revenueholdings-license is not installed " + "or if the license check fails. " + "Also enabled via REVENUEHOLDINGS_REQUIRE_LICENSE=1." + ), +) @click.pass_context -def main(ctx, no_gate) -> None: +def main(ctx, no_gate, require_license) -> None: """DeployDiff - Preview infrastructure changes with cost impact and rollback.""" ctx.ensure_object(dict) ctx.obj["no_gate"] = no_gate - if _HAS_RH_LICENSE and not no_gate: - require_license("deploydiff") + ctx.obj["require_license"] = require_license + if not no_gate: + if _HAS_RH_LICENSE: + from revenueholdings_license import require_license as _rl + _rl("deploydiff") + elif require_license: + console.print( + "[bold red]Error:[/bold red] revenueholdings-license is not installed. " + "Install it with: pip install revenueholdings-license" + ) + raise SystemExit(1) @main.command() From ceb84a97a31f7fb6c00f936005878a1367675f0e Mon Sep 17 00:00:00 2001 From: Jaixii Date: Mon, 29 Jun 2026 04:56:54 -0400 Subject: [PATCH 2/2] fix: rename require_license param to avoid shadowing module import --- src/deploydiff/cli.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/deploydiff/cli.py b/src/deploydiff/cli.py index 7bd6767..46902be 100644 --- a/src/deploydiff/cli.py +++ b/src/deploydiff/cli.py @@ -28,6 +28,7 @@ @click.option("--no-gate", is_flag=True, help="Skip license gating check.") @click.option( "--require-license", + "require_license_flag", is_flag=True, envvar="REVENUEHOLDINGS_REQUIRE_LICENSE", help=( @@ -37,16 +38,15 @@ ), ) @click.pass_context -def main(ctx, no_gate, require_license) -> None: +def main(ctx, no_gate, require_license_flag) -> None: """DeployDiff - Preview infrastructure changes with cost impact and rollback.""" ctx.ensure_object(dict) ctx.obj["no_gate"] = no_gate - ctx.obj["require_license"] = require_license + ctx.obj["require_license_flag"] = require_license_flag if not no_gate: if _HAS_RH_LICENSE: - from revenueholdings_license import require_license as _rl - _rl("deploydiff") - elif require_license: + require_license("deploydiff") + elif require_license_flag: console.print( "[bold red]Error:[/bold red] revenueholdings-license is not installed. " "Install it with: pip install revenueholdings-license"