mirror of https://github.com/ansible/ansible.git
ansible-test - Improve help for unsupported cwd. (#76866)
* ansible-test - Improve help for unsupported cwd. * The `--help` option is now available when an unsupported cwd is in use. * The `--help` output now shows the same instructions about cwd as would be shown in error messages if the cwd is unsupported. * Add `--version` support to show the ansible-core version. * The explanation about cwd usage has been improved to explain more clearly what is required. Resolves https://github.com/ansible/ansible/issues/64523 Resolves https://github.com/ansible/ansible/issues/67551pull/76869/head
parent
07bcd13e6f
commit
de5f60e374
@ -0,0 +1,5 @@
|
|||||||
|
minor_changes:
|
||||||
|
- ansible-test - The ``--help`` option is now available when an unsupported cwd is in use.
|
||||||
|
- ansible-test - The ``--help`` output now shows the same instructions about cwd as would be shown in error messages if the cwd is unsupported.
|
||||||
|
- ansible-test - Add ``--version`` support to show the ansible-core version.
|
||||||
|
- ansible-test - The explanation about cwd usage has been improved to explain more clearly what is required.
|
@ -0,0 +1,23 @@
|
|||||||
|
"""Argument parsing epilog generation."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from .argparsing import (
|
||||||
|
CompositeActionCompletionFinder,
|
||||||
|
)
|
||||||
|
|
||||||
|
from ..data import (
|
||||||
|
data_context,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_epilog(completer: CompositeActionCompletionFinder) -> str:
|
||||||
|
"""Generate and return the epilog to use for help output."""
|
||||||
|
if completer.enabled:
|
||||||
|
epilog = 'Tab completion available using the "argcomplete" python package.'
|
||||||
|
else:
|
||||||
|
epilog = 'Install the "argcomplete" python package to enable tab completion.'
|
||||||
|
|
||||||
|
if data_context().content.unsupported:
|
||||||
|
epilog += '\n\n' + data_context().explain_working_directory()
|
||||||
|
|
||||||
|
return epilog
|
@ -0,0 +1,42 @@
|
|||||||
|
"""Layout provider for an unsupported directory layout."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import typing as t
|
||||||
|
|
||||||
|
from . import (
|
||||||
|
ContentLayout,
|
||||||
|
LayoutProvider,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UnsupportedLayout(LayoutProvider):
|
||||||
|
"""Layout provider for an unsupported directory layout."""
|
||||||
|
sequence = 0 # disable automatic detection
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_content_root(path): # type: (str) -> bool
|
||||||
|
"""Return True if the given path is a content root for this provider."""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def create(self, root, paths): # type: (str, t.List[str]) -> ContentLayout
|
||||||
|
"""Create a Layout using the given root and paths."""
|
||||||
|
plugin_paths = dict((p, p) for p in self.PLUGIN_TYPES)
|
||||||
|
|
||||||
|
return ContentLayout(root,
|
||||||
|
paths,
|
||||||
|
plugin_paths=plugin_paths,
|
||||||
|
collection=None,
|
||||||
|
test_path='',
|
||||||
|
results_path='',
|
||||||
|
sanity_path='',
|
||||||
|
sanity_messages=None,
|
||||||
|
integration_path='',
|
||||||
|
integration_targets_path='',
|
||||||
|
integration_vars_path='',
|
||||||
|
integration_messages=None,
|
||||||
|
unit_path='',
|
||||||
|
unit_module_path='',
|
||||||
|
unit_module_utils_path='',
|
||||||
|
unit_messages=None,
|
||||||
|
unsupported=True,
|
||||||
|
)
|
@ -0,0 +1,22 @@
|
|||||||
|
"""Source provider to use when the layout is unsupported."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import typing as t
|
||||||
|
|
||||||
|
from . import (
|
||||||
|
SourceProvider,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UnsupportedSource(SourceProvider):
|
||||||
|
"""Source provider to use when the layout is unsupported."""
|
||||||
|
sequence = 0 # disable automatic detection
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_content_root(path): # type: (str) -> bool
|
||||||
|
"""Return True if the given path is a content root for this provider."""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_paths(self, path): # type: (str) -> t.List[str]
|
||||||
|
"""Return the list of available content paths under the given path."""
|
||||||
|
return []
|
Loading…
Reference in New Issue