def create_parser(): parser = argparse.ArgumentParser( description='Control your BigchainDB node.', parents=[utils.base_parser]) # all the commands are contained in the subparsers object, # the command selected by the user will be stored in `args.command` # that is used by the `main` function to select which other # function to call. subparsers = parser.add_subparsers(title='Commands', dest='command') # parser for writing a config file config_parser = subparsers.add_parser('configure', help='Prepare the config file.') config_parser.add_argument('backend', choices=['localmongodb'], default='localmongodb', const='localmongodb', nargs='?', help='The backend to use. It can only be ' '"localmongodb", currently.') # parser for managing elections election_parser = subparsers.add_parser('election', help='Manage elections.') election_subparser = election_parser.add_subparsers(title='Action', dest='action') new_election_parser = election_subparser.add_parser( 'new', help='Calls a new election.') new_election_subparser = new_election_parser.add_subparsers( title='Election_Type', dest='election_type') # Parser factory for each type of new election, so we get a bunch of commands that look like this: # election new <some_election_type> <args>... for name, data in elections.items(): args = data['args'] generic_parser = new_election_subparser.add_parser(name, help=data['help']) for arg, kwargs in args.items(): generic_parser.add_argument(arg, **kwargs) approve_election_parser = election_subparser.add_parser( 'approve', help='Approve the election.') approve_election_parser.add_argument( 'election_id', help='The election_id of the election.') approve_election_parser.add_argument( '--private-key', dest='sk', required=True, help='Path to the private key of the election initiator.') show_election_parser = election_subparser.add_parser( 'show', help='Provides information about an election.') show_election_parser.add_argument( 'election_id', help='The transaction id of the election you wish to query.') # parsers for showing/exporting config values subparsers.add_parser('show-config', help='Show the current configuration') # parser for database-level commands subparsers.add_parser('init', help='Init the database') subparsers.add_parser('drop', help='Drop the database') # parser for starting BigchainDB start_parser = subparsers.add_parser('start', help='Start BigchainDB') start_parser.add_argument('--no-init', dest='skip_initialize_database', default=False, action='store_true', help='Skip database initialization') subparsers.add_parser('tendermint-version', help='Show the Tendermint supported versions') start_parser.add_argument( '--experimental-parallel-validation', dest='experimental_parallel_validation', default=False, action='store_true', help= '💀 EXPERIMENTAL: parallelize validation for better throughput 💀') return parser
def create_parser(): parser = argparse.ArgumentParser( description='Control your BigchainDB node.', parents=[utils.base_parser]) # all the commands are contained in the subparsers object, # the command selected by the user will be stored in `args.command` # that is used by the `main` function to select which other # function to call. subparsers = parser.add_subparsers(title='Commands', dest='command') # parser for writing a config file config_parser = subparsers.add_parser('configure', help='Prepare the config file.') config_parser.add_argument('backend', choices=['localmongodb'], default='localmongodb', const='localmongodb', nargs='?', help='The backend to use. It can only be ' '"localmongodb", currently.') # parser for managing elections election_parser = subparsers.add_parser('election', help='Manage elections.') election_subparser = election_parser.add_subparsers(title='Action', dest='action') new_election_parser = election_subparser.add_parser('new', help='Calls a new election.') new_election_subparser = new_election_parser.add_subparsers(title='Election_Type', dest='election_type') # Parser factory for each type of new election, so we get a bunch of commands that look like this: # election new <some_election_type> <args>... for name, data in elections.items(): args = data['args'] generic_parser = new_election_subparser.add_parser(name, help=data['help']) for arg, kwargs in args.items(): generic_parser.add_argument(arg, **kwargs) approve_election_parser = election_subparser.add_parser('approve', help='Approve the election.') approve_election_parser.add_argument('election_id', help='The election_id of the election.') approve_election_parser.add_argument('--private-key', dest='sk', help='Path to the private key of the election initiator.') show_election_parser = election_subparser.add_parser('show', help='Provides information about an election.') show_election_parser.add_argument('election_id', help='The transaction id of the election you wish to query.') # parsers for showing/exporting config values subparsers.add_parser('show-config', help='Show the current configuration') # parser for database-level commands subparsers.add_parser('init', help='Init the database') subparsers.add_parser('drop', help='Drop the database') # parser for starting BigchainDB start_parser = subparsers.add_parser('start', help='Start BigchainDB') start_parser.add_argument('--no-init', dest='skip_initialize_database', default=False, action='store_true', help='Skip database initialization') return parser