diff --git a/scripts/Common/Scripts/software.fish b/scripts/Common/Scripts/software.fish index d038640c1..fa536a49f 100755 --- a/scripts/Common/Scripts/software.fish +++ b/scripts/Common/Scripts/software.fish @@ -2,35 +2,46 @@ begin set -l dir (status dirname) - function installSW - end - - function configureSW - end - - function userConfig -a user - end + functions -e installSW + functions -e configureSW + functions -e userConfig function runInstaller -V dir -a action + set -l path (status stack-trace | head -n4 | tail -n1 | string replace --regex -- '^\s*called on line \d+ of file (.*)$' '$1') + set -l name (basename (dirname $path)) + runInstallerAction $name $argv + end + + function runInstallerAction -V dir -a name action source "$dir/config.fish" if [ -z "$action" ] || [ "$action" = "install" ] - installSW $argv[2..] - runInstaller "configure" + if functions -q installSW + echo "Installing `$name`..." + installSW $argv[3..] + end + + runInstallerAction $name "configure" if not isConfigured || [ "$USER" != (getConfig "valhalla.setupUser.name") ] - runInstaller userConfig + runInstallerAction $name userConfig end else if [ "$action" = "configure" ] - configureSW $argv[2..] + if functions -q configureSW + echo "Configuring `$name`..." + configureSW $argv[3..] + end else if [ "$action" = "userConfig" ] - set -l name $argv[2] + set -l user $argv[3] - if [ -z "$name" ] - set name "$USER" + if [ -z "$user" ] + set user "$USER" end - userConfig "$name" $argv[3..] + if functions -q userConfig + echo "Configuring `$name` for `$user`..." + userConfig "$user" $argv[4..] + end end end end