diff --git a/scripts/lib/settings.fish b/scripts/lib/settings.fish index de16c2aa..63ae256a 100755 --- a/scripts/lib/settings.fish +++ b/scripts/lib/settings.fish @@ -40,13 +40,21 @@ function getOSConfig -S -a property getConfig "$(getOSConfigRoot).$property" $argv[2..] end -function getProgramConfig -S -a name user +function getProgramConfig -S + argparse -i "name=" "user=" -- $argv + set -l name $_flag_name + set -l user $_flag_user set -l option "programs.$name" + if [ -z "$name" ] + set name $argv[1] + set argv $argv[2..] + end + if [ -z "$user" ] - getOSConfig "$option" $argv[3..] --fallback "{}" + getOSConfig "$option" $argv --fallback "{}" else - getUserConfig "$user" "$option" $argv[3..] --fallback "{}" + getUserConfig "$user" "$option" $argv --fallback "{}" end end @@ -78,8 +86,9 @@ function isEnabled -S -a property getConfig "$property" --json | jq --exit-status >/dev/null end -function isProgramEnabled -S -a name user - getProgramConfig "$name" "$user" --json 2>/dev/null | jq --exit-status ".enable" >/dev/null +function isProgramEnabled -S + argparse -i "user=" "name=" -- $argv + getProgramConfig --user "$_flag_user" --name "$_flag_name" --json 2>/dev/null | jq --exit-status ".enable" >/dev/null end function isOSEnabled -S -a property diff --git a/scripts/lib/software.fish b/scripts/lib/software.fish index 430073f7..ee1778f1 100755 --- a/scripts/lib/software.fish +++ b/scripts/lib/software.fish @@ -117,7 +117,7 @@ begin set force false end - if isProgramEnabled $name || $force + if isProgramEnabled $args || $force set install true else set install false @@ -167,7 +167,7 @@ begin set -a args --user "$user" end - if isProgramEnabled "$name" "$user" || $force + if isProgramEnabled $args || $force set install true else set install false