diff --git a/_license-tool b/_license-tool new file mode 100644 index 0000000..bb2f396 --- /dev/null +++ b/_license-tool @@ -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' diff --git a/install.sh b/install.sh index db95e4f..97686d0 100755 --- a/install.sh +++ b/install.sh @@ -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"