Skip to content

Commit 94feadc

Browse files
committed
refactor: handle action_args for verify-policy.
Signed-off-by: Demolus13 <[email protected]>
1 parent c349423 commit 94feadc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/macaron/__main__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def verify_policy(verify_policy_args: argparse.Namespace) -> int:
196196
int
197197
Returns os.EX_OK if successful or the corresponding error code on failure.
198198
"""
199-
if not os.path.isfile(verify_policy_args.database):
199+
if not verify_policy_args.list_policies and not os.path.isfile(verify_policy_args.database):
200200
logger.critical("The database file does not exist.")
201201
return os.EX_OSFILE
202202

@@ -375,6 +375,9 @@ def perform_action(action_args: argparse.Namespace) -> None:
375375
case "verify-policy":
376376
if not action_args.disable_rich_output:
377377
rich_handler.start("verify-policy")
378+
if not action_args.list_policies and not action_args.database:
379+
logger.error("macaron verify-policy: error: the following arguments are required: -d/--database")
380+
sys.exit(os.EX_USAGE)
378381
sys.exit(verify_policy(action_args))
379382

380383
case "analyze":
@@ -631,7 +634,7 @@ def main(argv: list[str] | None = None) -> None:
631634
vp_parser = sub_parser.add_parser(name="verify-policy")
632635
vp_group = vp_parser.add_mutually_exclusive_group(required=True)
633636

634-
vp_parser.add_argument("-d", "--database", required=True, type=str, help="Path to the database.")
637+
vp_parser.add_argument("-d", "--database", type=str, help="Path to the database.")
635638
vp_parser.add_argument("-purl", "--package-url", help="PackageURL for policy template.")
636639
vp_group.add_argument("-f", "--file", type=str, help="Path to the Datalog policy.")
637640
vp_group.add_argument("-e", "--existing-policy", help="Name of the existing policy to run.")

0 commit comments

Comments
 (0)