add shell completion
This commit is contained in:
@@ -4,8 +4,10 @@
|
||||
, cargoToml
|
||||
, cargoLock
|
||||
, src
|
||||
, installShellFiles
|
||||
}:
|
||||
let
|
||||
mainProgram = (lib.head cargoToml.bin).name;
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = cargoToml.package.name;
|
||||
@@ -14,9 +16,20 @@ rustPlatform.buildRustPackage {
|
||||
|
||||
cargoLock.lockFile = cargoLock;
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
postInstall = let
|
||||
commands = lib.mapCartesianProduct ({ shell, command }: ''
|
||||
"$out/bin/${mainProgram}" generate-completions --shell "${shell}" --command "${command}" > "$TMP/mysqladm.${shell}"
|
||||
installShellCompletion "--${shell}" --cmd "${command}" "$TMP/mysqladm.${shell}"
|
||||
'') {
|
||||
shell = [ "bash" "zsh" "fish" ];
|
||||
command = [ "mysqladm" "mysql-dbadm" "mysql-useradm" ];
|
||||
};
|
||||
in lib.concatStringsSep "\n" commands;
|
||||
|
||||
meta = with lib; {
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
mainProgram = (lib.head cargoToml.bin).name;
|
||||
inherit mainProgram;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user