diff options
author | David Runge <dave@sleepmap.de> | 2021-09-28 20:30:24 +0200 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2021-09-28 20:30:24 +0200 |
commit | 7b3caefd51fc1aa334808a8a7f280b9fb10c7cfe (patch) | |
tree | 31fce8a73aa393cf596759ee54409eabec2e172a | |
parent | 1d4e03ca820d2ac6d57652ab00b45a848b494caf (diff) | |
download | dotfiles-7b3caefd51fc1aa334808a8a7f280b9fb10c7cfe.tar.gz dotfiles-7b3caefd51fc1aa334808a8a7f280b9fb10c7cfe.tar.bz2 dotfiles-7b3caefd51fc1aa334808a8a7f280b9fb10c7cfe.tar.xz dotfiles-7b3caefd51fc1aa334808a8a7f280b9fb10c7cfe.zip |
zsh: Add functions for nvchecker interaction
.zsh.functions/packaging.zsh:
Add some simple functions for nvchecker interaction.
-rw-r--r-- | .zsh.functions/packaging.zsh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/.zsh.functions/packaging.zsh b/.zsh.functions/packaging.zsh index 72627c7..69d6df4 100644 --- a/.zsh.functions/packaging.zsh +++ b/.zsh.functions/packaging.zsh @@ -84,3 +84,50 @@ sshfs_mount() { sshfs_umount() { fusermount3 -u "${HOME}/mounts/$1" } + +nvc() { + local config + if [[ -z "$1" ]]; then + 1>&2 printf "A repository name needs to be specified as the first argument.\n" + return 1 + fi + config="${HOME}/.config/nvchecker/$1.toml" + if [[ ! -f "${config}" ]]; then + 1>&2 printf "The configuration does not exist: %s\n" "${config}" + return 1 + fi + if ! command -v nvchecker > /dev/null; then + 1>&2 printf "The required application 'nvchecker' can not be found.\n" + return 1 + fi + nvchecker -c "${config}" +} + +nvt() { + local config package + if [[ -z "$1" ]]; then + 1>&2 printf "A repository name needs to be specified as the first argument.\n" + return 1 + fi + config="${HOME}/.config/nvchecker/$1.toml" + if [[ ! -f "${config}" ]]; then + 1>&2 printf "The configuration does not exist: %s\n" "${config}" + return 1 + fi + + if [[ -z "$2" ]]; then + 1>&2 printf "A package name needs to be specified as the second argument.\n" + return 1 + fi + package="${2}" + if ! grep "${package}" "${config}" > /dev/null; then + 1>&2 printf "The package %s can not be found in the configuration: %s\n" "${package}" "${config}" + return 1 + fi + + if ! command -v nvtake > /dev/null; then + 1>&2 printf "The required application 'nvtake' can not be found.\n" + return 1 + fi + nvtake -c "${config}" "${package}" +} |