Debian Codegraph @

test/lib/ansible_test/_internal/cli/commands/units.py

raw
1 """Command line parsing for the `units` command."""
2
3 from __future__ import annotations
4
5 import argparse
6
7 from ...config import (
8 UnitsConfig,
9 )
10
11 from ...commands.units import (
12 command_units,
13 )
14
15 from ...target import (
16 walk_units_targets,
17 )
18
19 from ..environments import (
20 CompositeActionCompletionFinder,
21 ControllerMode,
22 TargetMode,
23 add_environments,
24 )
25
26
27 def do_units(
28 subparsers,
29 parent: argparse.ArgumentParser,
30 completer: CompositeActionCompletionFinder,
31 ):
32 """Command line parsing for the `units` command."""
33 parser: argparse.ArgumentParser = subparsers.add_parser(
34 'units',
35 parents=[parent],
36 help='unit tests',
37 )
38
39 parser.set_defaults(
40 func=command_units,
41 targets_func=walk_units_targets,
42 config=UnitsConfig,
43 )
44
45 units = parser.add_argument_group(title='unit test arguments')
46
47 units.add_argument(
48 '--collect-only',
49 action='store_true',
50 help='collect tests but do not execute them',
51 )
52
53 units.add_argument(
54 '--num-workers',
55 metavar='INT',
56 type=int,
57 help='number of workers to use (default: auto)',
58 )
59
60 units.add_argument(
61 '--requirements-mode',
62 choices=('only', 'skip'),
63 help=argparse.SUPPRESS,
64 )
65
66 add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.UNITS) # units