Allow fetching program config with named args

This commit is contained in:
Manuel Thalmann 2024-11-02 22:45:22 +01:00
parent 9817747218
commit b5c1fbb935
2 changed files with 16 additions and 7 deletions

View file

@ -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

View file

@ -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