MCPcopy Index your code
hub / github.com/kyclark/tiny_python_projects / get_args

Function get_args

19_wod/solution2.py:14–52  ·  view source on GitHub ↗

Get command-line arguments

()

Source from the content-addressed store, hash-verified

12
13# --------------------------------------------------
14def get_args():
15 """Get command-line arguments"""
16
17 parser = argparse.ArgumentParser(
18 description='Create Workout Of (the) Day (WOD)',
19 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
20
21 parser.add_argument('-f',
22 '--file',
23 help='CSV input file of exercises',
24 metavar='FILE',
25 type=argparse.FileType('rt'),
26 default='inputs/exercises.csv')
27
28 parser.add_argument('-s',
29 '--seed',
30 help='Random seed',
31 metavar='seed',
32 type=int,
33 default=None)
34
35 parser.add_argument('-n',
36 '--num',
37 help='Number of exercises',
38 metavar='exercises',
39 type=int,
40 default=4)
41
42 parser.add_argument('-e',
43 '--easy',
44 help='Halve the reps',
45 action='store_true')
46
47 args = parser.parse_args()
48
49 if args.num < 1:
50 parser.error(f'--num "{args.num}" must be greater than 0')
51
52 return args
53
54
55# --------------------------------------------------

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected