home-assistant-cli: fix shell completions

This commit is contained in:
Mathieu Rene 2024-07-29 20:51:32 -04:00
parent 66fd9c6633
commit c7b8a912d0

View File

@ -1,7 +1,9 @@
{
lib,
stdenv,
fetchFromGitHub,
python3,
installShellFiles,
}:
python3.pkgs.buildPythonApplication rec {
@ -35,15 +37,14 @@ python3.pkgs.buildPythonApplication rec {
tabulate
];
# TODO: Completion needs to be adapted after support for latest click was added
# $ source <(_HASS_CLI_COMPLETE=bash_source hass-cli) # for bash
# $ source <(_HASS_CLI_COMPLETE=zsh_source hass-cli) # for zsh
# $ eval (_HASS_CLI_COMPLETE=fish_source hass-cli) # for fish
#postInstall = ''
# mkdir -p "$out/share/bash-completion/completions" "$out/share/zsh/site-functions"
# $out/bin/hass-cli completion bash > "$out/share/bash-completion/completions/hass-cli"
# $out/bin/hass-cli completion zsh > "$out/share/zsh/site-functions/_hass-cli"
#'';
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd hass-cli \
--bash <(_HASS_CLI_COMPLETE=bash_source $out/bin/hass-cli) \
--fish <(_HASS_CLI_COMPLETE=fish_source $out/bin/hass-cli) \
--zsh <(_HASS_CLI_COMPLETE=zsh_source $out/bin/hass-cli)
'';
nativeBuildInputs = [ installShellFiles ];
nativeCheckInputs = with python3.pkgs; [
pytestCheckHook