Add GenericCli utility

Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
Andrey Berezin 2024-02-14 16:16:59 +03:00
parent 4f3814690e
commit 751381cd60
8 changed files with 80 additions and 71 deletions

View file

@ -54,7 +54,7 @@ class Host(ABC):
raise ValueError(f"Unknown service name: '{service_name}'")
return service_config
def get_cli_config(self, cli_name: str) -> CLIConfig:
def get_cli_config(self, cli_name: str, allow_empty: bool = False) -> CLIConfig:
"""Returns config of CLI tool with specified name.
The CLI must be located on this host.
@ -66,7 +66,7 @@ class Host(ABC):
Config of the CLI tool.
"""
cli_config = self._cli_config_by_name.get(cli_name)
if cli_config is None:
if cli_config is None and not allow_empty:
raise ValueError(f"Unknown CLI name: '{cli_name}'")
return cli_config