-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_start.py
More file actions
27 lines (21 loc) · 740 Bytes
/
cli_start.py
File metadata and controls
27 lines (21 loc) · 740 Bytes
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
import argparse as ap
import logging
import sys
def run():
# setup logging
logger = logging.getLogger(__name__)
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO)
# test logging
logger.warning("LKJLJLj")
logger.info('Started')
## setup a parser for command line options
parser = ap.ArgumentParser()
# one optional argument of type int
parser.add_argument("-n", "--num", help="provide an integer value", type=int)
# one mandatory argument of any type
parser.add_argument("-t", "--text", help="a string value", required=True)
args = parser.parse_args()
logger.info(args.num)
logger.info(args.text)
if __name__ == "__main__":
run()