def test_strip(prefix: str, app_prefix: str, args_line: str, args_line_index: int) -> None: app_prefix = prefix + app_prefix if args_line: app_prefix = app_prefix + " " line = f"{app_prefix}{args_line}" result_line = BashCompletion.strip_python_or_app_name(line) assert result_line == args_line
def test_strip(prefix: str, app_prefix: str, args_line: str, args_line_index: int) -> None: app_prefix = prefix + app_prefix if args_line: app_prefix = app_prefix + " " line = "{}{}".format(app_prefix, args_line) result_line = BashCompletion.strip_python_or_app_name(line) assert result_line == args_line
class ZshCompletion(CompletionPlugin): def __init__(self, config_loader: ConfigLoader): super(ZshCompletion, self).__init__(config_loader) from hydra._internal.core_plugins.bash_completion import BashCompletion self.delegate = BashCompletion(config_loader) def install(self) -> None: self.delegate.install() def uninstall(self) -> None: self.delegate.uninstall() @staticmethod def provides() -> str: return "zsh" def query(self, config_name: Optional[str]) -> None: self.delegate.query(config_name) @staticmethod def help(command: str) -> str: assert command in ["install", "uninstall"] extra_description = ( "Zsh is compatible with the Bash shell completion, see the [documentation]" "(https://hydra.cc/docs/next/tutorials/basic/running_your_app/tab_completion#zsh-instructions)" " for details.\n ") command_text = f'eval "$({{}} -sc {command}=bash)"' if command == "install": return extra_description + command_text return command_text @staticmethod def _get_exec() -> str: from hydra._internal.core_plugins.bash_completion import BashCompletion return BashCompletion._get_exec()
def _get_exec() -> str: from hydra._internal.core_plugins.bash_completion import BashCompletion return BashCompletion._get_exec()
def __init__(self, config_loader: ConfigLoader): super(ZshCompletion, self).__init__(config_loader) from hydra._internal.core_plugins.bash_completion import BashCompletion self.delegate = BashCompletion(config_loader)