#!/bin/env fish begin set -l dir (status dirname) 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" ] if functions -q installSW echo "Installing `$name`..." installSW $argv[3..] end runInstallerAction $name "configure" if not isConfigured || [ "$USER" != (getConfig "valhalla.setupUser.name") ] runInstallerAction $name userConfig end else if [ "$action" = "configure" ] if functions -q configureSW echo "Configuring `$name`..." configureSW $argv[3..] end else if [ "$action" = "userConfig" ] set -l user $argv[3] if [ -z "$user" ] set user "$USER" end if functions -q userConfig echo "Configuring `$name` for `$user`..." userConfig "$user" $argv[4..] end end end end