Skip to content

Commit 3e1c42e

Browse files
feat: add --require-license strict mode flag (#39)
* feat: add --require-license strict mode flag Closes #32 * fix: rename require_license param to avoid shadowing module import
1 parent b65b525 commit 3e1c42e

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+
"require_license_flag",
32+
is_flag=True,
33+
envvar="REVENUEHOLDINGS_REQUIRE_LICENSE",
34+
help=(
35+
"Exit with an error if revenueholdings-license is not installed "
36+
"or if the license check fails. "
37+
"Also enabled via REVENUEHOLDINGS_REQUIRE_LICENSE=1."
38+
),
39+
)
2940
@click.pass_context
30-
def main(ctx, no_gate) -> None:
41+
def main(ctx, no_gate, require_license_flag) -> None:
3142
"""DeployDiff - Preview infrastructure changes with cost impact and rollback."""
3243
ctx.ensure_object(dict)
3344
ctx.obj["no_gate"] = no_gate
34-
if _HAS_RH_LICENSE and not no_gate:
35-
require_license("deploydiff")
45+
ctx.obj["require_license_flag"] = require_license_flag
46+
if not no_gate:
47+
if _HAS_RH_LICENSE:
48+
require_license("deploydiff")
49+
elif require_license_flag:
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)