Debian Codegraph @

test/lib/ansible_test/_internal/cli/actions.py

raw
1 """Actions for handling composite arguments with argparse."""
2
3 from __future__ import annotations
4
5 from .argparsing import (
6 CompositeAction,
7 NamespaceParser,
8 )
9
10 from .parsers import (
11 DelegatedControllerParser,
12 NetworkSshTargetParser,
13 NetworkTargetParser,
14 OriginControllerParser,
15 PosixSshTargetParser,
16 PosixTargetParser,
17 SanityPythonTargetParser,
18 UnitsPythonTargetParser,
19 WindowsSshTargetParser,
20 WindowsTargetParser,
21 )
22
23
24 class OriginControllerAction(CompositeAction):
25 """Composite action parser for the controller when the only option is `origin`."""
26
27 def create_parser(self) -> NamespaceParser:
28 """Return a namespace parser to parse the argument associated with this action."""
29 return OriginControllerParser()
30
31
32 class DelegatedControllerAction(CompositeAction):
33 """Composite action parser for the controller when delegation is supported."""
34
35 def create_parser(self) -> NamespaceParser:
36 """Return a namespace parser to parse the argument associated with this action."""
37 return DelegatedControllerParser()
38
39
40 class PosixTargetAction(CompositeAction):
41 """Composite action parser for a POSIX target."""
42
43 def create_parser(self) -> NamespaceParser:
44 """Return a namespace parser to parse the argument associated with this action."""
45 return PosixTargetParser()
46
47
48 class WindowsTargetAction(CompositeAction):
49 """Composite action parser for a Windows target."""
50
51 def create_parser(self) -> NamespaceParser:
52 """Return a namespace parser to parse the argument associated with this action."""
53 return WindowsTargetParser()
54
55
56 class NetworkTargetAction(CompositeAction):
57 """Composite action parser for a network target."""
58
59 def create_parser(self) -> NamespaceParser:
60 """Return a namespace parser to parse the argument associated with this action."""
61 return NetworkTargetParser()
62
63
64 class SanityPythonTargetAction(CompositeAction):
65 """Composite action parser for a sanity target."""
66
67 def create_parser(self) -> NamespaceParser:
68 """Return a namespace parser to parse the argument associated with this action."""
69 return SanityPythonTargetParser()
70
71
72 class UnitsPythonTargetAction(CompositeAction):
73 """Composite action parser for a units target."""
74
75 def create_parser(self) -> NamespaceParser:
76 """Return a namespace parser to parse the argument associated with this action."""
77 return UnitsPythonTargetParser()
78
79
80 class PosixSshTargetAction(CompositeAction):
81 """Composite action parser for a POSIX SSH target."""
82
83 def create_parser(self) -> NamespaceParser:
84 """Return a namespace parser to parse the argument associated with this action."""
85 return PosixSshTargetParser()
86
87
88 class WindowsSshTargetAction(CompositeAction):
89 """Composite action parser for a Windows SSH target."""
90
91 def create_parser(self) -> NamespaceParser:
92 """Return a namespace parser to parse the argument associated with this action."""
93 return WindowsSshTargetParser()
94
95
96 class NetworkSshTargetAction(CompositeAction):
97 """Composite action parser for a network SSH target."""
98
99 def create_parser(self) -> NamespaceParser:
100 """Return a namespace parser to parse the argument associated with this action."""
101 return NetworkSshTargetParser()