Improve safety and CLI fidelity for everyday use
Drop default --noconfirm (opt-in via --noconfirm), fix --noremovemake, forward pacman argv intact for -R/-D/-F/-T/-U, deepen PKGBUILD review, show an install plan before building, and add shellcheck CI plus unit tests. Co-authored-by: Frank Vitrano <WHC2006@users.noreply.github.com>
This commit is contained in:
co-authored by
Frank Vitrano
parent
d0f2cfe335
commit
bba71040d6
+63
-2
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2034
|
||||
# CLI parsing — paru-like short option clusters
|
||||
|
||||
# Globals set by parse_args
|
||||
@@ -61,9 +62,33 @@ Options:
|
||||
--mflags <flags> Pass additional flags to makepkg
|
||||
--sudoloop Keep sudo credentials alive (default)
|
||||
--nosudoloop Disable the sudo keep-alive loop
|
||||
--noconfirm Bypass any confirmation prompts
|
||||
EOF
|
||||
}
|
||||
|
||||
# Strip miaur-only options so the remainder can be forwarded to pacman.
|
||||
# Prints one argument per line (safe for mapfile with typical package names).
|
||||
strip_miaur_opts() {
|
||||
local -a raw=("$@")
|
||||
local i=0
|
||||
while ((i < ${#raw[@]})); do
|
||||
local arg=${raw[$i]}
|
||||
case "$arg" in
|
||||
--aur | --repo | --skipreview | --review | --cleanafter | --nocleanafter | \
|
||||
--removemake | --noremovemake | --noremovermake | --bottomup | --topdown | \
|
||||
--sudoloop | --nosudoloop | --noconfirm) ;;
|
||||
--clonedir | --mflags | --mode)
|
||||
i=$((i + 1))
|
||||
;;
|
||||
--clonedir=* | --mflags=* | --mode=*) ;;
|
||||
*)
|
||||
printf '%s\n' "$arg"
|
||||
;;
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
OP=S
|
||||
@@ -104,11 +129,14 @@ parse_args() {
|
||||
--cleanafter) MIAUR_CLEANAFTER=1 ;;
|
||||
--nocleanafter) MIAUR_CLEANAFTER=0 ;;
|
||||
--removemake) MIAUR_REMOVEMAKE=1 ;;
|
||||
--noremovemake) MIAUR_REMOVEMAKE=0 ;;
|
||||
# Typo alias kept for compatibility with older docs/scripts
|
||||
--noremovermake) MIAUR_REMOVEMAKE=0 ;;
|
||||
--bottomup) MIAUR_BOTTOMUP=1 ;;
|
||||
--topdown) MIAUR_BOTTOMUP=0 ;;
|
||||
--sudoloop) MIAUR_SUDOLOOP=1 ;;
|
||||
--nosudoloop) MIAUR_SUDOLOOP=0 ;;
|
||||
--noconfirm) MIAUR_NOCONFIRM=1 ;;
|
||||
--clonedir)
|
||||
i=$((i + 1))
|
||||
MIAUR_CLONEDIR=${raw[$i]:-}
|
||||
@@ -133,7 +161,20 @@ parse_args() {
|
||||
;;
|
||||
--getpkgbuild) OP=G ;;
|
||||
--build) OP=B ;;
|
||||
--database | --files | --deptest | --upgrade)
|
||||
--database)
|
||||
OP=D
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
--files)
|
||||
OP=F
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
--deptest)
|
||||
OP=T
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
--upgrade)
|
||||
OP=U
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
--)
|
||||
@@ -144,6 +185,11 @@ parse_args() {
|
||||
done
|
||||
break
|
||||
;;
|
||||
--*)
|
||||
# Unknown long option: keep for pacman passthrough (e.g. --ignore)
|
||||
PACMAN_EXTRA+=("$arg")
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
-*)
|
||||
local cluster=${arg:1}
|
||||
local j c
|
||||
@@ -158,7 +204,22 @@ parse_args() {
|
||||
;;
|
||||
G) OP=G ;;
|
||||
B) OP=B ;;
|
||||
D | F | T | U) DO_PASSTHRU=1 ;;
|
||||
D)
|
||||
OP=D
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
F)
|
||||
OP=F
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
T)
|
||||
OP=T
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
U)
|
||||
OP=U
|
||||
DO_PASSTHRU=1
|
||||
;;
|
||||
y) OP_REFRESH=1 ;;
|
||||
u) OP_UPGRADE=1 ;;
|
||||
s) OP_SEARCH=$((OP_SEARCH + 1)) ;;
|
||||
|
||||
Reference in New Issue
Block a user