Skip to content

Commit 988e763

Browse files
style: apply ruff format to src/deploydiff/cli.py
1 parent 9289193 commit 988e763

1 file changed

Lines changed: 81 additions & 17 deletions

File tree

src/deploydiff/cli.py

Lines changed: 81 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
try:
1717
from revenueholdings_license import require_license
18+
1819
_HAS_RH_LICENSE = True
1920
except ImportError:
2021
_HAS_RH_LICENSE = False
@@ -35,16 +36,35 @@ def main(ctx, no_gate) -> None:
3536

3637

3738
@main.command()
38-
@click.option("--tf", "terraform_file", type=click.Path(exists=True), help="Terraform plan JSON file")
39-
@click.option("--cfn", "cloudformation_file", type=click.Path(exists=True), help="CloudFormation change set JSON file")
40-
@click.option("--pulumi", "pulumi_file", type=click.Path(exists=True), help="Pulumi preview JSON file")
41-
@click.option("-v", "--verbose", is_flag=True, help="Show before/after details for each change")
39+
@click.option(
40+
"--tf",
41+
"terraform_file",
42+
type=click.Path(exists=True),
43+
help="Terraform plan JSON file",
44+
)
45+
@click.option(
46+
"--cfn",
47+
"cloudformation_file",
48+
type=click.Path(exists=True),
49+
help="CloudFormation change set JSON file",
50+
)
51+
@click.option(
52+
"--pulumi",
53+
"pulumi_file",
54+
type=click.Path(exists=True),
55+
help="Pulumi preview JSON file",
56+
)
57+
@click.option(
58+
"-v", "--verbose", is_flag=True, help="Show before/after details for each change"
59+
)
4260
@click.option(
4361
"--exit-on-destroy",
4462
is_flag=True,
4563
help="Exit with code 1 if the plan contains destructive changes (deletes or replaces)",
4664
)
47-
def preview(terraform_file, cloudformation_file, pulumi_file, verbose, exit_on_destroy) -> None:
65+
def preview(
66+
terraform_file, cloudformation_file, pulumi_file, verbose, exit_on_destroy
67+
) -> None:
4868
"""Preview infrastructure changes from a plan file."""
4969
plan = _load_plan(terraform_file, cloudformation_file, pulumi_file)
5070
if plan is None:
@@ -62,20 +82,43 @@ def preview(terraform_file, cloudformation_file, pulumi_file, verbose, exit_on_d
6282

6383

6484
@main.command()
65-
@click.option("--tf", "terraform_file", type=click.Path(exists=True), help="Terraform plan JSON file")
66-
@click.option("--cfn", "cloudformation_file", type=click.Path(exists=True), help="CloudFormation change set JSON file")
67-
@click.option("--pulumi", "pulumi_file", type=click.Path(exists=True), help="Pulumi preview JSON file")
68-
@click.option("--pricing", "pricing_file", type=click.Path(exists=True), help="Custom pricing JSON file")
85+
@click.option(
86+
"--tf",
87+
"terraform_file",
88+
type=click.Path(exists=True),
89+
help="Terraform plan JSON file",
90+
)
91+
@click.option(
92+
"--cfn",
93+
"cloudformation_file",
94+
type=click.Path(exists=True),
95+
help="CloudFormation change set JSON file",
96+
)
97+
@click.option(
98+
"--pulumi",
99+
"pulumi_file",
100+
type=click.Path(exists=True),
101+
help="Pulumi preview JSON file",
102+
)
103+
@click.option(
104+
"--pricing",
105+
"pricing_file",
106+
type=click.Path(exists=True),
107+
help="Custom pricing JSON file",
108+
)
69109
@click.option(
70110
"--threshold",
71111
type=float,
72112
default=None,
73113
help="Exit with code 1 if total monthly cost delta exceeds this value (e.g. 500 for $500)",
74114
)
75-
def cost(terraform_file, cloudformation_file, pulumi_file, pricing_file, threshold) -> None:
115+
def cost(
116+
terraform_file, cloudformation_file, pulumi_file, pricing_file, threshold
117+
) -> None:
76118
"""Estimate monthly cost impact of infrastructure changes. (Pro feature)"""
77119
if _HAS_RH_LICENSE:
78120
from revenueholdings_license import require_tier
121+
79122
require_tier("pro", "deploydiff cost")
80123
plan = _load_plan(terraform_file, cloudformation_file, pulumi_file)
81124
if plan is None:
@@ -95,13 +138,29 @@ def cost(terraform_file, cloudformation_file, pulumi_file, pricing_file, thresho
95138

96139

97140
@main.command()
98-
@click.option("--tf", "terraform_file", type=click.Path(exists=True), help="Terraform plan JSON file")
99-
@click.option("--cfn", "cloudformation_file", type=click.Path(exists=True), help="CloudFormation change set JSON file")
100-
@click.option("--pulumi", "pulumi_file", type=click.Path(exists=True), help="Pulumi preview JSON file")
141+
@click.option(
142+
"--tf",
143+
"terraform_file",
144+
type=click.Path(exists=True),
145+
help="Terraform plan JSON file",
146+
)
147+
@click.option(
148+
"--cfn",
149+
"cloudformation_file",
150+
type=click.Path(exists=True),
151+
help="CloudFormation change set JSON file",
152+
)
153+
@click.option(
154+
"--pulumi",
155+
"pulumi_file",
156+
type=click.Path(exists=True),
157+
help="Pulumi preview JSON file",
158+
)
101159
def rollback(terraform_file, cloudformation_file, pulumi_file) -> None:
102160
"""Generate rollback commands for infrastructure changes. (Pro feature)"""
103161
if _HAS_RH_LICENSE:
104162
from revenueholdings_license import require_tier
163+
105164
require_tier("pro", "deploydiff rollback")
106165
plan = _load_plan(terraform_file, cloudformation_file, pulumi_file)
107166
if plan is None:
@@ -113,7 +172,6 @@ def rollback(terraform_file, cloudformation_file, pulumi_file) -> None:
113172
console.print(cmd)
114173

115174

116-
117175
def _load_plan(
118176
terraform_file: str | None,
119177
cloudformation_file: str | None,
@@ -126,7 +184,9 @@ def _load_plan(
126184
if len(provided) == 0:
127185
return None
128186
if len(provided) > 1:
129-
console.print("[red]Error: Provide only one source file (--tf, --cfn, or --pulumi)[/red]")
187+
console.print(
188+
"[red]Error: Provide only one source file (--tf, --cfn, or --pulumi)[/red]"
189+
)
130190
raise SystemExit(1)
131191

132192
if terraform_file:
@@ -139,7 +199,9 @@ def _load_plan(
139199
return None
140200

141201

142-
def _render_costs(estimates: list[CostEstimate], plan: DeployPlan, console: Console) -> None:
202+
def _render_costs(
203+
estimates: list[CostEstimate], plan: DeployPlan, console: Console
204+
) -> None:
143205
"""Render cost estimates to the console."""
144206
from rich import box
145207
from rich.table import Table
@@ -172,7 +234,9 @@ def _render_costs(estimates: list[CostEstimate], plan: DeployPlan, console: Cons
172234
if total > 0:
173235
console.print(f"\n[bold red]Total monthly increase: +${total:.2f}[/bold red]")
174236
elif total < 0:
175-
console.print(f"\n[bold green]Total monthly decrease: -${abs(total):.2f}[/bold green]")
237+
console.print(
238+
f"\n[bold green]Total monthly decrease: -${abs(total):.2f}[/bold green]"
239+
)
176240
else:
177241
console.print("\n[bold]Total monthly change: $0.00[/bold]")
178242

0 commit comments

Comments
 (0)