#!/bin/bash # # __ # /\ \__ # __ _____\ \ ,_\ _____ __ ___ # /'__`\ /\ '__`\ \ \//\ '__`\ /'__`\ /'___\ #/\ \L\.\\ \ \L\ \ \ \\ \ \L\ /\ \L\.\_/\ \__/ #\ \__/.\_\ \ ,__/\ \__\ \ ,__\ \__/.\_\ \____\ # \/__/\/_/\ \ \/ \/__/\ \ \/ \/__/\/_/\/____/ # \ \_\ \ \_\ # \/_/ \/_/ # a pacman wrapper with syntax based on debian's apt # (c) 2019-2020 Fascode Network. # maintained by Yamada Hayao set -e OPTIONS= # List option installed=false _usage () { : } _exit () { exit ${1} } _msg_error () { echo -e "${@}" >&2 } ADD_OPTION () { OPTIONS="${OPTIONS} ${@}" } while getopts 'ydf-:' arg; do case "${arg}" in y) ADD_OPTION "--noconfirm" ;; d) ADD_OPTION "-w" ;; f) : ;; -) case "${OPTARG}" in download-only) ADD_OPTION "-w" ;; fix-broken) :;; yes) ADD_OPTION "--noconfirm" ;; assume-yes) ADD_OPTION "--noconfirm" ;; installed) installed=true; esac esac done shift $((OPTIND - 1)) if [[ $# -lt 1 ]]; then _msg_error "No command specified" _usage _exit 1 fi COMMAND="${1}" shift 1 PACKAGE="${@}" case "${COMMAND}" in install) ADD_OPTION "-S" ;; remove) ADD_OPTION "-Rsc" ;; purge) ADD_OPTION "-Rsnc" ;; update) ADD_OPTION "-Syy" ;; upgrade) ADD_OPTION "-Syu" ;; search) ADD_OPTION "-Ss" ;; list) if ${installed}; then ADD_OPTION "-Q | grep" else ADD_OPTION "-Ss" fi ;; *) _msg_error "Invalid comman '${COMMAND}'" _exit 1 ;; esac echo "pacman ${OPTIONS} ${PACKAGE}"