forked from cbh123/narrator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_arguments.py
34 lines (27 loc) · 976 Bytes
/
script_arguments.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
import argparse
def make_arguments(parser_description):
parser = argparse.ArgumentParser(description=parser_description)
# Boolean
parser.add_argument(
"--from-error",
action="store_true",
help="If the script was run from an error of another narrator. It stores the Boolean value True if the specified argument is present in the command line and False otherwise."
)
# Text is conditionally required
parser.add_argument(
"--text",
type=str,
default=None,
help="Text to say at first instance of speech. Required if --from-error is True."
)
# Boolean
parser.add_argument(
"--debug-camera",
action="store_true",
help="If you want to debug the camera."
)
args = parser.parse_args()
# Conditional requirement check
if args.from_error and not args.text:
parser.error("--text is required when --from-error is specified.")
return args