Rename to pet

This commit is contained in:
Case Duckworth 2022-01-25 22:54:42 -06:00
parent ecd99a7e83
commit d63a9ab203
1 changed files with 24 additions and 24 deletions

48
opm.sh → pet.sh Normal file → Executable file
View File

@ -4,56 +4,56 @@
# Linux distros are pretty similar, except they all have different package
# managers and it's hard to remember what's what, when all you want to do is
# install `sl` or the latest meme editor. OPM aims to help with this by mapping
# install `sl` or the latest meme editor. PET aims to help with this by mapping
# common package-management transactions to one easy-to-remember command list.
# There are two ways that this improves over other one-size-fits-all package
# managers: (A) you can use whichever your favorite package manager's syntax is
# by setting `$OPM_ARGUMENT_STYLE`; and (B) you don't have to call OPM with the
# name OPM.
# by setting `$PET_ARGUMENT_STYLE`; and (B) you don't have to call PET with the
# name PET.
# OPM can be symlinked to another filename on disk, or renamed; if it's called
# by that name (and it maps to one of OPM's known package managers), it will use
# PET can be symlinked to another filename on disk, or renamed; if it's called
# by that name (and it maps to one of PET's known package managers), it will use
# that manager's syntax for the transaction. It will also warn the user
# (depending on the value of `$OPM_WARN_ALTERNATE`, which defaults to true) that
# (depending on the value of `$PET_WARN_ALTERNATE`, which defaults to true) that
# they're currently in another distro, and if they want to do more complex
# package management, they need to use that distro's manager.
# Indeed, the philosophy of OPM stipulates that most of the time, only a certain
# Indeed, the philosophy of PET stipulates that most of the time, only a certain
# subset of package management transactions are necessary, and those most common
# transactions are supported by the vast majority of package managers. Anything
# more complicated will likely be distro- or package-manager-specific, and is
# better served by using that particular manager.
: "${OPM_ARGUMENT_STYLE:=opm}"
: "${OPM_WARN_ALTERNATE:=true}"
: "${PET_ARGUMENT_STYLE:=pet}"
: "${PET_WARN_ALTERNATE:=true}"
## OPM_PACKAGE_MANAGERS is a space-separated list of supported package managers.
OPM_PACKAGE_MANAGERS="opm"
## PET_PACKAGE_MANAGERS is a space-separated list of supported package managers.
PET_PACKAGE_MANAGERS="pet"
### Dispatching
opm_executable_p() { # opm_executable_p NAME
pet_executable_p() { # pet_executable_p NAME
## Return success if NAME exists in $PATH and is executable, else fail.
command -v "$1" >/dev/null 2>&1
}
opm_package_manager() {
pet_package_manager() {
## Figure out what package manager to perform transactions as.
# If $0 is something other than opm or opm.sh, use that. Else, if
# $OPM_ARGUMENT_STYLE exists on the system, use that. Else, try all the
# package managers OPM knows about, and use the first found.
# If $0 is something other than pet or pet.sh, use that. Else, if
# $PET_ARGUMENT_STYLE exists on the system, use that. Else, try all the
# package managers PET knows about, and use the first found.
case "$0" in
*opm|*opm.sh) echo opm ;;
*pet|*pet.sh) echo pet ;;
*)
if ! [ "$OPM_ARGUMENT_STYLE" = opm ] &&
opm_executable_p "$OPM_ARGUMENT_STYLE"; then
echo "$OPM_ARGUMENT_STYLE"
if ! [ "$PET_ARGUMENT_STYLE" = pet ] &&
pet_executable_p "$PET_ARGUMENT_STYLE"; then
echo "$PET_ARGUMENT_STYLE"
else
set -- $OPM_PACKAGE_MANAGERS # no quotes intentional
set -- $PET_PACKAGE_MANAGERS # no quotes intentional
for pm; do
if opm_executable_p "$pm"; then
echo "$OPM_ARGUMENT_STYLE"
if pet_executable_p "$pm"; then
echo "$PET_ARGUMENT_STYLE"
return 0
fi
return 1 # not found
@ -61,7 +61,7 @@ opm_package_manager() {
fi
}
opm_dispatch() { # opm_dispatch PACKAGE_MANAGER TRANSACTION PACKAGE
pet_dispatch() { # pet_dispatch PACKAGE_MANAGER TRANSACTION PACKAGE
## Perform TRANSACTION on PACKAGE, using PACKAGE_MANAGER.
}