integration-testing/client/CasperClient/casper_client/casper_client.py
def command_line_tool():
    """
    Parse command line and call an appropriate command.
    """

    class Parser:
        def __init__(self):
            self.parser = argparse.ArgumentParser(add_help=False)
            self.parser.add_argument('--help', action='help', default=argparse.SUPPRESS,
                                     help='show this help message and exit')
            self.parser.add_argument('-h', '--host', required=False, default=DEFAULT_HOST, type=str,
                                     help='Hostname or IP of node on which gRPC service is running.')
            self.parser.add_argument('-p', '--port', required=False, default=DEFAULT_PORT, type=int,
                                     help='Port used for external gRPC API.')
            self.parser.add_argument('--internal-port', required=False, default=DEFAULT_INTERNAL_PORT, type=int,
                                     help='Port used for internal gRPC API.')
            self.sp = self.parser.add_subparsers(help='Choose a request')

        def addCommand(self, command: str, function, help, arguments):
            command_parser = self.sp.add_parser(command, help=help)
            command_parser.set_defaults(function=function)
            for (args, options) in arguments:
                command_parser.add_argument(*args, **options)

        def run(self):
            if len(sys.argv) < 2:
                self.parser.print_usage()
                return 1

            args = self.parser.parse_args()
            return args.function(CasperClient(args.host, args.port, args.internal_port), args)

    parser = Parser()
    parser.addCommand('deploy', deploy_command, 'Deploy a smart contract source file to Casper on an existing running node. The deploy will be packaged and sent as a block to the network depending on the configuration of the Casper instance',
                      [[('-f', '--from'), dict(required=True, type=lambda x: bytes(x, 'utf-8'), help='Purse address that will be used to pay for the deployment.')],
                       [('-g', '--gas-limit'), dict(required=True, type=int, help='[Deprecated] The amount of gas to use for the transaction (unused gas is refunded). Must be positive integer.')],
                       [('--gas-price',), dict(required=False, type=int, default=10, help='The price of gas for this transaction in units dust/gas. Must be positive integer.')],
                       [('-n', '--nonce'), dict(required=True, type=int, help='This allows you to overwrite your own pending transactions that use the same nonce.')],
                       [('-p', '--payment'), dict(required=False, type=str, default=None, help='Path to the file with payment code, by default fallbacks to the --session code')],
                       [('-s', '--session'), dict(required=True, type=str, help='Path to the file with session code')],
                       [('--args',), dict(required=False, type=str, help='JSON encoded list of args, e.g.: [{"u32":1024},{"u64":12}]')],
                       [('--private-key',), dict(required=True, type=str, help='Path to the file with account public key (Ed25519)')],
                       [('--public-key',), dict(required=True, type=str, help='Path to the file with account private key (Ed25519)')]])

    parser.addCommand('propose', propose_command, 'Force a node to propose a block based on its accumulated deploys.', [])

    parser.addCommand('show-block', show_block_command, 'View properties of a block known by Casper on an existing running node. Output includes: parent hashes, storage contents of the tuplespace.',
                      [[('hash',), dict(type=str, help='the hash value of the block')]])

    parser.addCommand('show-blocks', show_blocks_command, 'View list of blocks in the current Casper view on an existing running node.',
                      [[('-d', '--depth'), dict(required=True, type=int, help='depth in terms of block height')]])

    parser.addCommand('show-deploy', show_deploy_command, 'View properties of a deploy known by Casper on an existing running node.',
                      [[('hash',), dict(type=str, help='Value of the deploy hash, base16 encoded.')]])

    parser.addCommand('show-deploys', show_deploys_command, 'View deploys included in a block.',
                      [[('hash',), dict(type=str, help='Value of the block hash, base16 encoded.')]])

    parser.addCommand('vdag', vdag_command, 'DAG in DOT format',
                      [[('-d', '--depth'), dict(required=True, type=int, help='depth in terms of block height')],
                       [('-o', '--out'), dict(required=False, type=str, help='output image filename, outputs to stdout if not specified, must end with one of the png, svg, svg_standalone, xdot, plain, plain_ext, ps, ps2, json, json0')],
                       [('-s', '--show-justification-lines'), dict(action='store_true', help='if justification lines should be shown')],
                       [('--stream',), dict(required=False, choices=('single-output', 'multiple-outputs'), help="subscribe to changes, '--out' has to be specified, valid values are 'single-output', 'multiple-outputs'")]])

    parser.addCommand('query-state', query_state_command, 'Query a value in the global state.',
                      [[('-b', '--block-hash'), dict(required=True, type=str, help='Hash of the block to query the state of')],
                       [('-k', '--key'), dict(required=True, type=str, help='Base16 encoding of the base key')],
                       [('-p', '--path'), dict(required=True, type=str, help="Path to the value to query. Must be of the form 'key1/key2/.../keyn'")],
                       [('-t', '--type'), dict(required=True, choices=('hash', 'uref', 'address'), help="Type of base key. Must be one of 'hash', 'uref', 'address'")]])

    sys.exit(parser.run())

    Parse command line and call an appropriate command.
    
Parse command line and call an appropriate command.
Parse command line and call an appropriate command .
def command_line_tool():
    class Parser:
        def __init__(self):
            self.parser = argparse.ArgumentParser(add_help=False)
            self.parser.add_argument('--help', action='help', default=argparse.SUPPRESS,
                                     help='show this help message and exit')
            self.parser.add_argument('-h', '--host', required=False, default=DEFAULT_HOST, type=str,
                                     help='Hostname or IP of node on which gRPC service is running.')
            self.parser.add_argument('-p', '--port', required=False, default=DEFAULT_PORT, type=int,
                                     help='Port used for external gRPC API.')
            self.parser.add_argument('--internal-port', required=False, default=DEFAULT_INTERNAL_PORT, type=int,
                                     help='Port used for internal gRPC API.')
            self.sp = self.parser.add_subparsers(help='Choose a request')
        def addCommand(self, command: str, function, help, arguments):
            command_parser = self.sp.add_parser(command, help=help)
            command_parser.set_defaults(function=function)
            for (args, options) in arguments:
                command_parser.add_argument(*args, **options)
        def run(self):
            if len(sys.argv) < 2:
                self.parser.print_usage()
                return 1
            args = self.parser.parse_args()
            return args.function(CasperClient(args.host, args.port, args.internal_port), args)
    parser = Parser()
    parser.addCommand('deploy', deploy_command, 'Deploy a smart contract source file to Casper on an existing running node. The deploy will be packaged and sent as a block to the network depending on the configuration of the Casper instance',
                      [[('-f', '--from'), dict(required=True, type=lambda x: bytes(x, 'utf-8'), help='Purse address that will be used to pay for the deployment.')],
                       [('-g', '--gas-limit'), dict(required=True, type=int, help='[Deprecated] The amount of gas to use for the transaction (unused gas is refunded). Must be positive integer.')],
                       [('--gas-price',), dict(required=False, type=int, default=10, help='The price of gas for this transaction in units dust/gas. Must be positive integer.')],
                       [('-n', '--nonce'), dict(required=True, type=int, help='This allows you to overwrite your own pending transactions that use the same nonce.')],
                       [('-p', '--payment'), dict(required=False, type=str, default=None, help='Path to the file with payment code, by default fallbacks to the --session code')],
                       [('-s', '--session'), dict(required=True, type=str, help='Path to the file with session code')],
                       [('--args',), dict(required=False, type=str, help='JSON encoded list of args, e.g.: [{"u32":1024},{"u64":12}]')],
                       [('--private-key',), dict(required=True, type=str, help='Path to the file with account public key (Ed25519)')],
                       [('--public-key',), dict(required=True, type=str, help='Path to the file with account private key (Ed25519)')]])
    parser.addCommand('propose', propose_command, 'Force a node to propose a block based on its accumulated deploys.', [])
    parser.addCommand('show-block', show_block_command, 'View properties of a block known by Casper on an existing running node. Output includes: parent hashes, storage contents of the tuplespace.',
                      [[('hash',), dict(type=str, help='the hash value of the block')]])
    parser.addCommand('show-blocks', show_blocks_command, 'View list of blocks in the current Casper view on an existing running node.',
                      [[('-d', '--depth'), dict(required=True, type=int, help='depth in terms of block height')]])
    parser.addCommand('show-deploy', show_deploy_command, 'View properties of a deploy known by Casper on an existing running node.',
                      [[('hash',), dict(type=str, help='Value of the deploy hash, base16 encoded.')]])
    parser.addCommand('show-deploys', show_deploys_command, 'View deploys included in a block.',
                      [[('hash',), dict(type=str, help='Value of the block hash, base16 encoded.')]])
    parser.addCommand('vdag', vdag_command, 'DAG in DOT format',
                      [[('-d', '--depth'), dict(required=True, type=int, help='depth in terms of block height')],
                       [('-o', '--out'), dict(required=False, type=str, help='output image filename, outputs to stdout if not specified, must end with one of the png, svg, svg_standalone, xdot, plain, plain_ext, ps, ps2, json, json0')],
                       [('-s', '--show-justification-lines'), dict(action='store_true', help='if justification lines should be shown')],
                       [('--stream',), dict(required=False, choices=('single-output', 'multiple-outputs'), help="subscribe to changes, '--out' has to be specified, valid values are 'single-output', 'multiple-outputs'")]])
    parser.addCommand('query-state', query_state_command, 'Query a value in the global state.',
                      [[('-b', '--block-hash'), dict(required=True, type=str, help='Hash of the block to query the state of')],
                       [('-k', '--key'), dict(required=True, type=str, help='Base16 encoding of the base key')],
                       [('-p', '--path'), dict(required=True, type=str, help="Path to the value to query. Must be of the form 'key1/key2/.../keyn'")],
                       [('-t', '--type'), dict(required=True, choices=('hash', 'uref', 'address'), help="Type of base key. Must be one of 'hash', 'uref', 'address'")]])
    sys.exit(parser.run())
def command_line_tool ( ) : class Parser : def __init__ ( self ) : self . parser = argparse . ArgumentParser ( add_help = False ) self . parser . add_argument ( '--help' , action = 'help' , default = argparse . SUPPRESS , help = 'show this help message and exit' ) self . parser . add_argument ( '-h' , '--host' , required = False , default = DEFAULT_HOST , type = str , help = 'Hostname or IP of node on which gRPC service is running.' ) self . parser . add_argument ( '-p' , '--port' , required = False , default = DEFAULT_PORT , type = int , help = 'Port used for external gRPC API.' ) self . parser . add_argument ( '--internal-port' , required = False , default = DEFAULT_INTERNAL_PORT , type = int , help = 'Port used for internal gRPC API.' ) self . sp = self . parser . add_subparsers ( help = 'Choose a request' ) def addCommand ( self , command : str , function , help , arguments ) : command_parser = self . sp . add_parser ( command , help = help ) command_parser . set_defaults ( function = function ) for ( args , options ) in arguments : command_parser . add_argument ( * args , ** options ) def run ( self ) : if len ( sys . argv ) < 2 : self . parser . print_usage ( ) return 1 args = self . parser . parse_args ( ) return args . function ( CasperClient ( args . host , args . port , args . internal_port ) , args ) parser = Parser ( ) parser . addCommand ( 'deploy' , deploy_command , 'Deploy a smart contract source file to Casper on an existing running node. The deploy will be packaged and sent as a block to the network depending on the configuration of the Casper instance' , [ [ ( '-f' , '--from' ) , dict ( required = True , type = lambda x : bytes ( x , 'utf-8' ) , help = 'Purse address that will be used to pay for the deployment.' ) ] , [ ( '-g' , '--gas-limit' ) , dict ( required = True , type = int , help = '[Deprecated] The amount of gas to use for the transaction (unused gas is refunded). Must be positive integer.' ) ] , [ ( '--gas-price' , ) , dict ( required = False , type = int , default = 10 , help = 'The price of gas for this transaction in units dust/gas. Must be positive integer.' ) ] , [ ( '-n' , '--nonce' ) , dict ( required = True , type = int , help = 'This allows you to overwrite your own pending transactions that use the same nonce.' ) ] , [ ( '-p' , '--payment' ) , dict ( required = False , type = str , default = None , help = 'Path to the file with payment code, by default fallbacks to the --session code' ) ] , [ ( '-s' , '--session' ) , dict ( required = True , type = str , help = 'Path to the file with session code' ) ] , [ ( '--args' , ) , dict ( required = False , type = str , help = 'JSON encoded list of args, e.g.: [{"u32":1024},{"u64":12}]' ) ] , [ ( '--private-key' , ) , dict ( required = True , type = str , help = 'Path to the file with account public key (Ed25519)' ) ] , [ ( '--public-key' , ) , dict ( required = True , type = str , help = 'Path to the file with account private key (Ed25519)' ) ] ] ) parser . addCommand ( 'propose' , propose_command , 'Force a node to propose a block based on its accumulated deploys.' , [ ] ) parser . addCommand ( 'show-block' , show_block_command , 'View properties of a block known by Casper on an existing running node. Output includes: parent hashes, storage contents of the tuplespace.' , [ [ ( 'hash' , ) , dict ( type = str , help = 'the hash value of the block' ) ] ] ) parser . addCommand ( 'show-blocks' , show_blocks_command , 'View list of blocks in the current Casper view on an existing running node.' , [ [ ( '-d' , '--depth' ) , dict ( required = True , type = int , help = 'depth in terms of block height' ) ] ] ) parser . addCommand ( 'show-deploy' , show_deploy_command , 'View properties of a deploy known by Casper on an existing running node.' , [ [ ( 'hash' , ) , dict ( type = str , help = 'Value of the deploy hash, base16 encoded.' ) ] ] ) parser . addCommand ( 'show-deploys' , show_deploys_command , 'View deploys included in a block.' , [ [ ( 'hash' , ) , dict ( type = str , help = 'Value of the block hash, base16 encoded.' ) ] ] ) parser . addCommand ( 'vdag' , vdag_command , 'DAG in DOT format' , [ [ ( '-d' , '--depth' ) , dict ( required = True , type = int , help = 'depth in terms of block height' ) ] , [ ( '-o' , '--out' ) , dict ( required = False , type = str , help = 'output image filename, outputs to stdout if not specified, must end with one of the png, svg, svg_standalone, xdot, plain, plain_ext, ps, ps2, json, json0' ) ] , [ ( '-s' , '--show-justification-lines' ) , dict ( action = 'store_true' , help = 'if justification lines should be shown' ) ] , [ ( '--stream' , ) , dict ( required = False , choices = ( 'single-output' , 'multiple-outputs' ) , help = "subscribe to changes, '--out' has to be specified, valid values are 'single-output', 'multiple-outputs'" ) ] ] ) parser . addCommand ( 'query-state' , query_state_command , 'Query a value in the global state.' , [ [ ( '-b' , '--block-hash' ) , dict ( required = True , type = str , help = 'Hash of the block to query the state of' ) ] , [ ( '-k' , '--key' ) , dict ( required = True , type = str , help = 'Base16 encoding of the base key' ) ] , [ ( '-p' , '--path' ) , dict ( required = True , type = str , help = "Path to the value to query. Must be of the form 'key1/key2/.../keyn'" ) ] , [ ( '-t' , '--type' ) , dict ( required = True , choices = ( 'hash' , 'uref' , 'address' ) , help = "Type of base key. Must be one of 'hash', 'uref', 'address'" ) ] ] ) sys . exit ( parser . run ( ) )
Parse command line and call an appropriate command.
Parse command line and call an appropriate command .
"""
    Parse command line and call an appropriate command.
    """