Skip to content

Commit

Permalink
Merge branch 'main' into michael/help-messages-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
liav-certora committed Jan 8, 2025
2 parents 606ca99 + bc9b231 commit 9e76bf0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
68 changes: 49 additions & 19 deletions Quorum/entry_points/quorum_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@

import argparse
from pydantic import BaseModel
from typing import Callable

import Quorum.entry_points.cli_arguments as cli_args
from Quorum.entry_points.implementations.check_proposal import run_single
from Quorum.entry_points.implementations.check_proposal_config import run_config
from Quorum.entry_points.implementations.check_proposal_id import run_proposal_id
from Quorum.entry_points.implementations.create_report import run_create_report
from Quorum.entry_points.implementations.ipfs_validator import run_ipfs_validator
from Quorum.entry_points.implementations.setup_quorum import run_setup_quorum


class Command(BaseModel):
name: str
help: str
arguments: list[cli_args.Argument]
func: Callable[[argparse.Namespace], None]


COMMAND_REGISTRY = [
Expand All @@ -29,13 +21,11 @@ class Command(BaseModel):
cli_args.TEMPLATE_ARGUMENT,
cli_args.OUTPUT_PATH_ARGUMENT
],
func=run_create_report
),
Command(
name="setup",
help="Sets up Quorum environment for quick start.",
arguments=[cli_args.WORKING_DIR_ARGUMENT],
func=run_setup_quorum
),
Command(
name="validate-address",
Expand All @@ -45,22 +35,28 @@ class Command(BaseModel):
cli_args.CHAIN_ARGUMENT,
cli_args.PAYLOAD_ADDRESS_ARGUMENT
],
func=run_single
),
Command(
name="validate-batch",
help="Validate multiple on-chain payloads sequentially using a JSON config file.",
arguments=[cli_args.CONFIG_ARGUMENT],
func=run_config
help="Run a batch check from a JSON config file.",
arguments=[cli_args.CONFIG_ARGUMENT]
),
Command(
name="validate-by-id",
help="Validate a single on-chain proposal by passing the protocol name and id.",
arguments=[
cli_args.PROTOCOL_NAME_ARGUMENT,
cli_args.PROPOSAL_ID_ARGUMENT
],
func=run_proposal_id
]
),
Command(
name="create-report",
help="Generate a proposal report.",
arguments=[
cli_args.PROPOSAL_ID_ARGUMENT,
cli_args.TEMPLATE_ARGUMENT,
cli_args.OUTPUT_PATH_ARGUMENT
]
),
Command(
name="validate-ipfs",
Expand All @@ -70,8 +66,12 @@ class Command(BaseModel):
cli_args.CHAIN_ARGUMENT,
cli_args.PAYLOAD_ADDRESS_ARGUMENT,
cli_args.PROMPT_TEMPLATES_ARGUMENT
],
func=run_ipfs_validator
]
),
Command(
name="setup",
help="Initial Quorum environment setup.",
arguments=[cli_args.WORKING_DIR_ARGUMENT]
)
]

Expand Down Expand Up @@ -105,7 +105,37 @@ def main():
help=subcmd.help
)
add_arguments(subparser, subcmd.arguments)
subparser.set_defaults(func=subcmd.func)

if subcmd.name == "validate-address":
def run(args):
from Quorum.entry_points.implementations.check_proposal import run_single
run_single(args)
subparser.set_defaults(func=run)
elif subcmd.name == "validate-batch":
def run(args):
from Quorum.entry_points.implementations.check_proposal_config import run_config
run_config(args)
subparser.set_defaults(func=run)
elif subcmd.name == "validate-by-id":
def run(args):
from Quorum.entry_points.implementations.check_proposal_id import run_proposal_id
run_proposal_id(args)
subparser.set_defaults(func=run)
elif subcmd.name == "create-report":
def run(args):
from Quorum.entry_points.implementations.create_report import run_create_report
run_create_report(args)
subparser.set_defaults(func=run)
elif subcmd.name == "validate-ipfs":
def run(args):
from Quorum.entry_points.implementations.ipfs_validator import run_ipfs_validator
run_ipfs_validator(args)
subparser.set_defaults(func=run)
elif subcmd.name == "setup":
def run(args):
from Quorum.entry_points.implementations.setup_quorum import run_setup_quorum
run_setup_quorum(args)
subparser.set_defaults(func=run)

args = parser.parse_args()

Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20250107.200733.615539
20250108.022018.555389

0 comments on commit 9e76bf0

Please sign in to comment.