diff options
| author | pml68 <contact@pml68.dev> | 2025-09-07 12:03:10 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-09-07 12:03:10 +0200 |
| commit | c70c80c789df88aa4ed079c7f8b6fcd4a23cb095 (patch) | |
| tree | c3bc5cba5b744c0af99d331e7f3d5185cd501b39 | |
| parent | feat: add Makefile (diff) | |
| download | aur-c70c80c789df88aa4ed079c7f8b6fcd4a23cb095.tar.gz | |
feat: add -r/--remove flags
| -rwxr-xr-x | aur | 38 | ||||
| -rw-r--r-- | aur.1 | 3 | ||||
| -rw-r--r-- | shell-completions/aur-completion.bash | 10 | ||||
| -rw-r--r-- | shell-completions/aur.completor.bash | 8 | ||||
| -rw-r--r-- | shell-completions/aur.fish | 3 | ||||
| -rwxr-xr-x | tools/release | 13 |
6 files changed, 64 insertions, 11 deletions
@@ -1,6 +1,7 @@ #!/bin/bash { set -eu + [[ -n ${AUR_DEBUG-} ]] && set -x version=1.0.0 @@ -10,15 +11,16 @@ echo "Provides basic AUR package management functionality, showing users a diff before upgrading a package." echo "" echo "Options:" - echo " <pkg1 pkg2 ...> Download and install/update the specified packages." - echo " -g, --git Checks all packages for updates and rebuilds all -git packages." - echo " -c, --config <file> Parse the specified config file and install/update" - echo " packages listed in it (one per line)." - echo " -f, --force Reinstall all packages, even if they are up-to-date." - echo " -l, --list List currently installed packages." - echo " -h, --help Display this help text." - echo " -v, --version Prints program version." - echo " [nothing] Check all packages for updates." + echo " <pkg1 pkg2 ...> Download and install/update the specified packages." + echo " -r, --remove <pkg1 pkg2 ...> Remove the specified packages. Runs pacman -Rns" + echo " -g, --git Checks all packages for updates and rebuilds all -git packages." + echo " -c, --config <file> Parse the specified config file and install/update" + echo " packages listed in it (one per line)." + echo " -f, --force Reinstall all packages, even if they are up-to-date." + echo " -l, --list List currently installed packages." + echo " -h, --help Display this help text." + echo " -v, --version Prints program version." + echo " [nothing] Check all packages for updates." echo "" exit "${1-0}" } @@ -74,6 +76,20 @@ done } + _remove() { + for package in "$@"; do + if pacman -Qi "$package"; then + if [[ -d ~/.aur/"$package" ]]; then + read -p "Removing ~/.aur/$package. Continue? [Y/n] " proceed + if [[ -z "$proceed" ]] || [[ "$proceed" == "Y" ]] || [[ "$proceed" == "y" ]]; then + rm -rf ~/.aur/"$package" + fi + fi + sudo pacman -Rns "$package" + fi + done + } + if [[ -n "${1-}" ]]; then case "$1" in --list | -l) @@ -95,6 +111,10 @@ --version | -v) _version ;; + --remove | -r) + shift + _remove "$@" + ;; -*) echo "Unknown option: $1" echo "" @@ -12,6 +12,9 @@ Provides basic AUR package management functionality, showing users a diff before <pkg1 pkg2 ...> Download and install/update the specified packages. .TP +\fB\-r\fR, \fB\-\-remove\fR <pkg1 pkg2 ...> +Remove the specified packages. Runs pacman \fB\-Rns\fR +.TP \fB\-g\fR, \fB\-\-git\fR Checks all packages for updates and rebuilds all \fB\-git\fR packages. .TP diff --git a/shell-completions/aur-completion.bash b/shell-completions/aur-completion.bash index 224f1ee..c365c2e 100644 --- a/shell-completions/aur-completion.bash +++ b/shell-completions/aur-completion.bash @@ -12,7 +12,7 @@ # shellcheck disable=2207 # editorconfig-checker-disable -_aur_comp_cmd_opts=( -h --help -v --version -l --list -f --force -g --git -c --config ) +_aur_comp_cmd_opts=( -h --help -v --version -l --list -f --force -g --git -c --config -r --remove ) _aur_comp_reply_aur_pkgs () @@ -59,6 +59,12 @@ _aur_comp_reply_list () eval "COMPREPLY=( \$(compgen -W \"$array_list\" -- \"\$cur\") )" } +_aur_comp_reply_pacman () +{ + pkgs=$(pacman -Qqm | paste -d ' ' -s -); + COMPREPLY=($(compgen -W "$pkgs" -- "$cur")) +} + _aur_comp_reply_words () { local IFS=$'\n'; @@ -95,6 +101,8 @@ _aur_completions() { # rely the value of command option -c) _aur_comp_reply_files ;; --config) _aur_comp_reply_files ;; + -r) _aur_comp_reply_pacman ;; + --remove) _aur_comp_reply_pacman ;; *) _aur_comp_reply_aur_pkgs ;; esac else diff --git a/shell-completions/aur.completor.bash b/shell-completions/aur.completor.bash index cb83422..0479f73 100644 --- a/shell-completions/aur.completor.bash +++ b/shell-completions/aur.completor.bash @@ -10,6 +10,8 @@ cmd_opts=( -g --git -c:@files --config:@files + -r:@pacman + --remove:@pacman ) reply_aur_pkgs() { @@ -17,3 +19,9 @@ reply_aur_pkgs() { COMPREPLY=( $(compgen -W "$pkgs" -- "$cur") ) } + +reply_pacman() { + pkgs=$(pacman -Qqm | paste -d ' ' -s -) + + COMPREPLY=( $(compgen -W "$pkgs" -- "$cur") ) +} diff --git a/shell-completions/aur.fish b/shell-completions/aur.fish index ae54b02..b66ebad 100644 --- a/shell-completions/aur.fish +++ b/shell-completions/aur.fish @@ -1,5 +1,5 @@ function _aur_no_switches - not __fish_contains_opt -s h help -s v version -s l list -s f force -s g git -s c config + not __fish_contains_opt -s h help -s v version -s l list -s f force -s g git -s c config -s r remove end complete -c aur -f @@ -9,4 +9,5 @@ complete -c aur -s v -l version complete -c aur -s l -l list complete -c aur -s f -l force complete -c aur -s g -l git +complete -c aur -s r -l remove -a "(pacman -Qqm)" complete -c aur -s c -l config -F -r diff --git a/tools/release b/tools/release new file mode 100755 index 0000000..065b5ce --- /dev/null +++ b/tools/release @@ -0,0 +1,13 @@ +#!/bin/bash + +if [[ -n "$1" ]]; then + set -xe + sed -i "s/version=.*/version=$1/" ./aur + make -B + git add . + git commit -m "chore: bump version" + git tag -a "v$1" -m "aur v$1" +else + echo "No version argument passed." + exit 1 +fi |
