From 41c7ce03d8c7dfb5ecf23beee1e3d690fa88e3d3 Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Fri, 21 Jun 2019 00:34:26 +0530 Subject: [PATCH] Add help command --- mythril/interfaces/cli.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mythril/interfaces/cli.py b/mythril/interfaces/cli.py index a0f4e2f1..97e5c57d 100644 --- a/mythril/interfaces/cli.py +++ b/mythril/interfaces/cli.py @@ -40,6 +40,7 @@ COMMAND_LIST = ( "hash-to-address", "version", "truffle", + "help", ) ) @@ -209,18 +210,18 @@ def main() -> None: subparsers.add_parser( "version", parents=[output_parser], help="Outputs the version" ) - create_read_storage_parser(read_storage_parser) create_hash_to_addr_parser(contract_hash_to_addr) create_func_to_hash_parser(contract_func_to_hash) create_leveldb_parser(leveldb_search_parser) subparsers.add_parser("truffle", parents=[analyzer_parser], add_help=False) + subparsers.add_parser("help", add_help=False) # Get config values args = parser.parse_args() - parse_args(parser=parser, args=args) + parse_args_and_execute(parser=parser, args=args) def create_disassemble_parser(parser: ArgumentParser): @@ -627,7 +628,7 @@ def contract_hash_to_address(args: Namespace): sys.exit() -def parse_args(parser: ArgumentParser, args: Namespace) -> None: +def parse_args_and_execute(parser: ArgumentParser, args: Namespace) -> None: """ Parses the arguments :param parser: The parser @@ -649,6 +650,10 @@ def parse_args(parser: ArgumentParser, args: Namespace) -> None: print("Mythril version {}".format(VERSION)) sys.exit() + if args.command == "help": + parser.print_help() + sys.exit() + # Parse cmdline args validate_args(args) try: