refactored if statements to switch case
This commit is contained in:
parent
e2789d200b
commit
b1306a73b4
129
pman.sh
129
pman.sh
@ -45,64 +45,77 @@ if [ "$command" = "" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Evaluate the command arguments
|
# Evaluate the command arguments
|
||||||
if [ "$command_args" = "search" ]; then
|
case "$command_args" in
|
||||||
command_args="-Ss"
|
"search")
|
||||||
elif [ "$command_args" = "provides" ]; then
|
command_args="-Ss"
|
||||||
# Update the cache
|
;;
|
||||||
su_needed=true
|
"provides")
|
||||||
command_args="-Fy"
|
# Update the cache
|
||||||
execute_command "${@}"
|
su_needed=true
|
||||||
|
command_args="-Fy"
|
||||||
|
execute_command "${@}"
|
||||||
|
|
||||||
su_needed=false
|
su_needed=false
|
||||||
command_args="-F"
|
command_args="-F"
|
||||||
elif [ "$command_args" = "installed" ]; then
|
;;
|
||||||
command_args="-Q"
|
"installed")
|
||||||
elif [ "$command_args" = "install" ]; then
|
command_args="-Q"
|
||||||
command_args="-S"
|
;;
|
||||||
if [ "$command" = "pacman" ]; then
|
"install")
|
||||||
su_needed=true
|
command_args="-S"
|
||||||
fi
|
if [ "$command" = "pacman" ]; then
|
||||||
elif [ "$command_args" = "update" ]; then
|
su_needed=true
|
||||||
command_args="-Sy"
|
fi
|
||||||
if [ "$command" = "pacman" ]; then
|
;;
|
||||||
su_needed=true
|
"update")
|
||||||
fi
|
command_args="-Sy"
|
||||||
elif [ "$command_args" = "upgradable" ]; then
|
if [ "$command" = "pacman" ]; then
|
||||||
command_args="-Qu"
|
su_needed=true
|
||||||
elif [ "$command_args" = "upgrade" ]; then
|
fi
|
||||||
command_args="-Syu"
|
;;
|
||||||
if [ "$command" = "pacman" ]; then
|
"upgradable")
|
||||||
su_needed=true
|
command_args="-Qu"
|
||||||
fi
|
;;
|
||||||
elif [ "$command_args" = "remove" ]; then
|
"upgrade")
|
||||||
command_args="-Rs"
|
command_args="-Syu"
|
||||||
if [ "$command" = "pacman" ]; then
|
if [ "$command" = "pacman" ]; then
|
||||||
su_needed=true
|
su_needed=true
|
||||||
fi
|
fi
|
||||||
elif [ "$command_args" = "purge" ]; then
|
;;
|
||||||
command_args="-Rns"
|
"remove")
|
||||||
if [ "$command" = "pacman" ]; then
|
command_args="-Rs"
|
||||||
su_needed=true
|
if [ "$command" = "pacman" ]; then
|
||||||
fi
|
su_needed=true
|
||||||
elif [ "$more_arguments" = "true" ]; then
|
fi
|
||||||
echo "Invalid command: \"$command $command_args\""
|
;;
|
||||||
echo
|
"purge")
|
||||||
echo "Usage: pman <command> [args...]"
|
command_args="-Rns"
|
||||||
echo "Available commands:"
|
if [ "$command" = "pacman" ]; then
|
||||||
echo " yay (aur) - yay | invoke yay "
|
su_needed=true
|
||||||
echo " (aur packages - all the normal operations except config are available)"
|
fi
|
||||||
echo " aur (yay) - yay | same as \"yay\""
|
;;
|
||||||
echo " search - pacman -Ss | search packages"
|
*)
|
||||||
echo " provides - pacman -F | list packages that provide file"
|
if [ "$more_arguments" = "true" ]; then
|
||||||
echo " installed - pacman -Q | list installed packages"
|
echo "Invalid command: \"$command $command_args\""
|
||||||
echo " install - pacman -S | install packages"
|
echo
|
||||||
echo " update - pacman -Sy | updates the repositories"
|
echo "Usage: pman <command> [args...]"
|
||||||
echo " upgradable - pacman -Qu | list available upgrades"
|
echo "Available commands:"
|
||||||
echo " upgrade - pacman -Syu | upgrades your system"
|
echo " yay (aur) - yay | invoke yay "
|
||||||
echo " remove - pacman -Rs | remove packages & dependencies"
|
echo " (aur packages - all the normal operations except config are available)"
|
||||||
echo " purge - pacman -Rns | remove packages, dependencies & conf"
|
echo " aur (yay) - yay | same as \"yay\""
|
||||||
echo " config - /etc/pacman.conf | edits pacman configuration"
|
echo " search - pacman -Ss | search packages"
|
||||||
exit 1
|
echo " provides - pacman -F | list packages that provide file"
|
||||||
fi
|
echo " installed - pacman -Q | list installed packages"
|
||||||
|
echo " install - pacman -S | install packages"
|
||||||
|
echo " update - pacman -Sy | updates the repositories"
|
||||||
|
echo " upgradable - pacman -Qu | list available upgrades"
|
||||||
|
echo " upgrade - pacman -Syu | upgrades your system"
|
||||||
|
echo " remove - pacman -Rs | remove packages & dependencies"
|
||||||
|
echo " purge - pacman -Rns | remove packages, dependencies & conf"
|
||||||
|
echo " config - /etc/pacman.conf | edits pacman configuration"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
execute_command "${@}"
|
execute_command "${@}"
|
||||||
|
Loading…
Reference in New Issue
Block a user