diff --git a/source/yeet b/source/yeet index b2d2b9a..80ce6b9 100755 --- a/source/yeet +++ b/source/yeet @@ -257,6 +257,8 @@ search_regex="\-s" remove_regex="\-Rs*" # yeet -B - Build an AUR package build_regex="\-B" +# yeet -C - Clear build directory +clean_regex="\-C" # yeet -D/F/Q/T [options] - Run pacman -D/F/Q/T pacman_regex="\-[DFQT].*" # yeet - Search for a package and install it @@ -291,6 +293,11 @@ if [[ "$1" =~ $option_regex ]] || [[ -z "$1" ]]; then operation="build" # Shift the params so the second one is the first, the third is the second and so on shift + elif [[ "$1" =~ $clean_regex ]]; then + # Clear cache dir + operation="clean" + # Shift the params so the second one is the first, the third is the second and so on + shift elif [[ "$1" =~ $pacman_regex ]]; then # If the first option is -D/F/Q/T and the like (e.g., -Dkk, -Fy, -Ql, -Tv), then let pacman handle it operation="pacman" @@ -315,7 +322,8 @@ function help { printw "\e[0;34mInstall the specified package(s) \e[1;33m yeet -S " printw "\e[0;34mRemove the specified package(s) \e[1;33m yeet -R " printw "\e[0;34mBuild an AUR package \e[1;33m yeet -B " - printw "\e[0;34mRun pacman -D \e[1;33m yeet -D [options]" + printw "\e[0;34mClear cache directory \e[1;33m yeet -C" + printw "\e[0;34mRun pacman -D \e[1;33m yeet -D [options]" printw "\e[0;34mRun pacman -F \e[1;33m yeet -F [options]" printw "\e[0;34mRun pacman -Q \e[1;33m yeet -Q [options]" printw "\e[0;34mRun pacman -T \e[1;33m yeet -T [options]" @@ -537,6 +545,19 @@ function build_packages { printw "==> Package built; but not installed. Run \`yeet -B $1\` again if you want to install the package." fi } +# Clear the build dir +function clean { + printb "==> Clearing cache directory ($CACHE_DIR)" + # Ask the user if they want to clear the build directory + read -p $'\e[1;33m ==> Are you sure you want to clear the cache directory?\e[0m [\e[1;32my\e[0m/\e[1;31mN\e[0m] ' -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]]; then + printb "\n==> Removing cache directory..." + rm -rf "$CACHE_DIR" + printg "==> Deleted cache directory!" + else + printr "==> Aborted by user!" + fi +} # Search for a package and install it function searchinstall_packages { # Search for packages @@ -562,6 +583,7 @@ case "$operation" in "updateinstall") updateinstall_packages $*;; "remove") remove_packages $*;; "build") build_packages $*;; + "clean") clean $*;; "pacman") require_root $PACMAN_BIN $*;; "searchinstall") searchinstall_packages $*;; esac