-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargument_parser.py
62 lines (57 loc) · 2.04 KB
/
argument_parser.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
53
54
55
56
57
58
59
60
61
62
import argparse
class ValidateCopyArtifact(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
if len(values) % 2 != 0:
parser.error(
f"argument {option_string}: You must provide pairs of remote-path and local-output."
)
setattr(namespace, self.dest, values)
def parse_arguments():
parser = argparse.ArgumentParser(
description="Run commands on remote devices provisioned on Torizon Cloud."
)
parser.add_argument(
"--copy-artifact",
nargs="+",
metavar=("remote-path", "local-output"),
action=ValidateCopyArtifact,
help=(
"Copies multiple files over Remote Access from the target device "
"to local-output. Specify pairs of remote-path and local-output."
),
)
parser.add_argument(
# arguments without leading `--` are assumed to be positional and not
# optional. Use nargs='?' to force the last command to be optional.
"command",
type=str,
nargs="?",
help="Command to run on target device.",
)
parser.add_argument(
"--before",
type=str,
help="Command to run before the main command on target device.",
)
parser.add_argument(
"--delegation-config",
type=str,
help="Path of config which tells Aval how to parse the target delegation.",
)
parser.add_argument(
"--device-config",
type=str,
help="Path of config which tells Aval which device to match.",
)
parser.add_argument(
"--run-before-on-host",
type=str,
help="Command to be executed on host (the machine calling aval) after locking and updating the device.",
)
parser.add_argument(
"--pid-map",
type=str,
help="Path of a PID4 map yaml file describing devices and their properties. By default it tries to use a `pid_map.yaml` located in the directory where Aval is called from.",
)
args = parser.parse_args()
return args