Skip to content

Commit 7239088

Browse files
feat: add --require-license strict mode flag
Closes #32
1 parent b65b525 commit 7239088

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

src/deploydiff/cli.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,32 @@
2626
@click.group()
2727
@click.version_option(package_name="deploydiff")
2828
@click.option("--no-gate", is_flag=True, help="Skip license gating check.")
29+
@click.option(
30+
"--require-license",
31+
is_flag=True,
32+
envvar="REVENUEHOLDINGS_REQUIRE_LICENSE",
33+
help=(
34+
"Exit with an error if revenueholdings-license is not installed "
35+
"or if the license check fails. "
36+
"Also enabled via REVENUEHOLDINGS_REQUIRE_LICENSE=1."
37+
),
38+
)
2939
@click.pass_context
30-
def main(ctx, no_gate) -> None:
40+
def main(ctx, no_gate, require_license) -> None:
3141
"""DeployDiff - Preview infrastructure changes with cost impact and rollback."""
3242
ctx.ensure_object(dict)
3343
ctx.obj["no_gate"] = no_gate
34-
if _HAS_RH_LICENSE and not no_gate:
35-
require_license("deploydiff")
44+
ctx.obj["require_license"] = require_license
45+
if not no_gate:
46+
if _HAS_RH_LICENSE:
47+
from revenueholdings_license import require_license as _rl
48+
_rl("deploydiff")
49+
elif require_license:
50+
console.print(
51+
"[bold red]Error:[/bold red] revenueholdings-license is not installed. "
52+
"Install it with: pip install revenueholdings-license"
53+
)
54+
raise SystemExit(1)
3655

3756

3857
@main.command()

0 commit comments

Comments
 (0)