-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli_parser_args.py
52 lines (44 loc) · 2.68 KB
/
cli_parser_args.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import argparse
def add_arguments(parser: argparse.ArgumentParser):
"""Add subparsers and necessary arguments to the main cli parser
Args:
parser (argparse.ArgumentParser): The parser to update
"""
sub = parser.add_subparsers(help='Operation to execute')
parser_add_node = sub.add_parser('add_node', help='Add node to blockchain')
parser_add_node.set_defaults(which='node')
parser_add_node.add_argument('-p', '--port', default=-1, type=int,
help='Port to listen on')
parser_add_node.add_argument('-i', '--index', default=-1, type=int,
help='Index of node')
parser_add_node.add_argument('-c', '--capacity', default=-1, type=int,
help='Blockchain capacity')
parser_add_node.add_argument('-d', '--difficulty', default=-1, type=int,
help='Blockchain difficulty')
parser_add_node.add_argument('-n', '--number_nodes', default=-1, type=int,
help='The total number of nodes')
parser_transaction = sub.add_parser('add_transaction',
help='Add transaction to blockchain')
parser_transaction.set_defaults(which='transaction')
parser_transaction.add_argument('-r', '--recipient', default=-1, type=str,
help='Transaction\'s recipient address')
parser_transaction.add_argument('-s', '--sender', default=-1, type=str,
help='Transaction\'s sender address')
parser_transaction.add_argument('-a', '--amount', default=-1, type=int,
help='Amount to be sent')
parser_view = sub.add_parser('view', help='View last transactions\
(transactions of last valid block)')
parser_view.set_defaults(which='view')
parser_view.add_argument('-n', '--node', default=-1, type=str,
help='The node\'s address, from which to view\
transactions')
parser_balance = sub.add_parser('balance', help='Print balance of a\
specific node')
parser_balance.set_defaults(which='balance')
parser_balance.add_argument('-n', '--node', default=-1, type=str,
help='The node\'s address, for which to print\
the balance')
parser_balance = sub.add_parser('broadcast_nodes', help='Broadcast\
bootstrap blockchain and ring node to\
all nodes')
parser_balance.set_defaults(which='broadcast_nodes')