Skip to content

Commit 58b8f7b

Browse files
committed
enhancing output logic
1 parent f778af2 commit 58b8f7b

2 files changed

Lines changed: 15 additions & 19 deletions

File tree

devolv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.21"
1+
__version__ = "0.1.22"

devolv/iam/validator/cli.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,26 @@ def validate(
2020
findings = []
2121
if os.path.isfile(path):
2222
findings = validate_policy_file(path)
23+
if not findings:
24+
typer.secho("✅ Policy is valid and passed all checks.", fg=typer.colors.GREEN)
25+
elif json_output:
26+
typer.echo(json.dumps(findings, indent=2))
27+
else:
28+
for finding in findings:
29+
typer.secho(
30+
f"❌ {finding.get('level', '').upper()}: {finding.get('message', '')}",
31+
fg=typer.colors.RED
32+
)
2333
elif os.path.isdir(path):
2434
findings = validate_policy_folder(path)
35+
if json_output:
36+
typer.echo(json.dumps(findings, indent=2))
37+
# No re-print of findings — already handled by folder validator
2538
else:
2639
typer.secho(f"❌ Unsupported path type: {path}", fg=typer.colors.RED)
2740
raise Exit(code=1)
2841

29-
if not findings:
30-
msg = (
31-
"✅ Policy is valid and passed all checks."
32-
if os.path.isfile(path)
33-
else "✅ All policies passed validation."
34-
)
35-
typer.secho(msg, fg=typer.colors.GREEN)
36-
raise Exit(code=0)
37-
38-
if json_output:
39-
typer.echo(json.dumps(findings, indent=2))
40-
else:
41-
for finding in findings:
42-
typer.secho(
43-
f"❌ {finding.get('level', '').upper()}: {finding.get('message', '')}",
44-
fg=typer.colors.RED
45-
)
46-
42+
# Determine exit code
4743
if any(f.get("level", "").lower() in ("error", "high") for f in findings):
4844
raise Exit(code=1)
4945
else:

0 commit comments

Comments
 (0)