Debian Codegraph @

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

raw
1 """Command line parsing for the `shell` command."""
2
3 from __future__ import annotations
4
5 import argparse
6
7 from ...commands.shell import (
8 command_shell,
9 )
10
11 from ...config import (
12 ShellConfig,
13 )
14
15 from ..environments import (
16 CompositeActionCompletionFinder,
17 ControllerMode,
18 TargetMode,
19 add_environments,
20 )
21
22
23 def do_shell(
24 subparsers,
25 parent: argparse.ArgumentParser,
26 completer: CompositeActionCompletionFinder,
27 ):
28 """Command line parsing for the `shell` command."""
29 parser: argparse.ArgumentParser = subparsers.add_parser(
30 'shell',
31 parents=[parent],
32 help='open an interactive shell',
33 )
34
35 parser.set_defaults(
36 func=command_shell,
37 config=ShellConfig,
38 )
39
40 shell = parser.add_argument_group(title='shell arguments')
41
42 shell.add_argument(
43 'cmd',
44 nargs='*',
45 help='run the specified command',
46 )
47
48 shell.add_argument(
49 '--raw',
50 action='store_true',
51 help='direct to shell with no setup',
52 )
53
54 shell.add_argument(
55 '--export',
56 metavar='PATH',
57 help='export inventory instead of opening a shell',
58 )
59
60 add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.SHELL) # shell