esptool: add shell completions

Now that esptool uses 'click', we can use its machinery to generate
the completions.
This commit is contained in:
Stefan Frijters
2025-08-25 18:24:21 +02:00
parent 11be587109
commit 2971c65784
+28 -1
View File
@@ -3,6 +3,7 @@
fetchFromGitHub,
python3Packages,
softhsm,
installShellFiles,
}:
python3Packages.buildPythonApplication rec {
@@ -43,9 +44,35 @@ python3Packages.buildPythonApplication rec {
hsm = [ python-pkcs11 ];
};
nativeBuildInputs = [
installShellFiles
];
postInstall = ''
rm -v $out/bin/*.py
'';
''
+
lib.strings.concatMapStrings
(
cmd:
# Unfortunately, espsecure and espefuse do not run in cross-compilation
lib.optionalString
(
python3Packages.stdenv.buildPlatform.canExecute python3Packages.stdenv.hostPlatform
|| cmd == "esptool"
)
''
installShellCompletion --cmd ${cmd} \
--bash <(_${lib.toUpper cmd}_COMPLETE=bash_source $out/bin/${cmd}) \
--zsh <(_${lib.toUpper cmd}_COMPLETE=zsh_source $out/bin/${cmd}) \
--fish <(_${lib.toUpper cmd}_COMPLETE=fish_source $out/bin/${cmd})
''
)
[
"esptool"
"espsecure"
"espefuse"
];
nativeCheckInputs =
with python3Packages;