Added zsh completion

This commit is contained in:
Alexander Rosenberg 2023-05-01 17:31:06 -07:00
parent 978d9c686e
commit f6dbf614d1
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
2 changed files with 25 additions and 0 deletions

24
_license-tool Normal file
View File

@ -0,0 +1,24 @@
#compdef license-tool
_license-tool_files() {
# system dir
local system_dir="/usr/share/license-tool/"
for file in "${system_dir}"**(N); do
compadd -X "[system]" "${file#"${system_dir}"}"
done
# user dir
if [[ -v XDG_CONFIG_HOME ]]; then
local user_dir="${XDG_CONFIG_HOME}/license-tool/"
else
local user_dir="${HOME}/.config/license-tool/"
fi
for file in "${user_dir}"**(N); do
compadd -X "[user]" "${file#"${user_dir}"}"
done
}
_arguments \
'-h[print help]' \
'-o[output file]:output:_files' \
'*:license:_license-tool_files'

View File

@ -12,6 +12,7 @@ cargo build --release
sudo sh << EOF
cp target/release/license-tool "$PREFIX/bin/license-tool"
cp _license-tool "$PREFIX/share/zsh/site-functions/_license-tool"
printf "Installing licenses to '%s'\n" "$GLOBAL_DATA_PATH"
rm -rf "$GLOBAL_DATA_PATH"
cp -R licenses "$GLOBAL_DATA_PATH"