From 7b3caefd51fc1aa334808a8a7f280b9fb10c7cfe Mon Sep 17 00:00:00 2001 From: David Runge Date: Tue, 28 Sep 2021 20:30:24 +0200 Subject: zsh: Add functions for nvchecker interaction .zsh.functions/packaging.zsh: Add some simple functions for nvchecker interaction. --- .zsh.functions/packaging.zsh | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to '.zsh.functions') 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}" +} -- cgit v1.2.3-54-g00ecf