Allow fetching program config with named args
This commit is contained in:
parent
f47a1f56f5
commit
1cc07f9bda
2 changed files with 16 additions and 7 deletions
|
@ -40,13 +40,21 @@ function getOSConfig -S -a property
|
||||||
getConfig "$(getOSConfigRoot).$property" $argv[2..]
|
getConfig "$(getOSConfigRoot).$property" $argv[2..]
|
||||||
end
|
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"
|
set -l option "programs.$name"
|
||||||
|
|
||||||
|
if [ -z "$name" ]
|
||||||
|
set name $argv[1]
|
||||||
|
set argv $argv[2..]
|
||||||
|
end
|
||||||
|
|
||||||
if [ -z "$user" ]
|
if [ -z "$user" ]
|
||||||
getOSConfig "$option" $argv[3..] --fallback "{}"
|
getOSConfig "$option" $argv --fallback "{}"
|
||||||
else
|
else
|
||||||
getUserConfig "$user" "$option" $argv[3..] --fallback "{}"
|
getUserConfig "$user" "$option" $argv --fallback "{}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,8 +86,9 @@ function isEnabled -S -a property
|
||||||
getConfig "$property" --json | jq --exit-status >/dev/null
|
getConfig "$property" --json | jq --exit-status >/dev/null
|
||||||
end
|
end
|
||||||
|
|
||||||
function isProgramEnabled -S -a name user
|
function isProgramEnabled -S
|
||||||
getProgramConfig "$name" "$user" --json 2>/dev/null | jq --exit-status ".enable" >/dev/null
|
argparse -i "user=" "name=" -- $argv
|
||||||
|
getProgramConfig --user "$_flag_user" --name "$_flag_name" --json 2>/dev/null | jq --exit-status ".enable" >/dev/null
|
||||||
end
|
end
|
||||||
|
|
||||||
function isOSEnabled -S -a property
|
function isOSEnabled -S -a property
|
||||||
|
|
|
@ -121,7 +121,7 @@ begin
|
||||||
set force false
|
set force false
|
||||||
end
|
end
|
||||||
|
|
||||||
if isProgramEnabled $name || $force
|
if isProgramEnabled $args || $force
|
||||||
set install true
|
set install true
|
||||||
else
|
else
|
||||||
set install false
|
set install false
|
||||||
|
@ -171,7 +171,7 @@ begin
|
||||||
set -a args --user "$user"
|
set -a args --user "$user"
|
||||||
end
|
end
|
||||||
|
|
||||||
if isProgramEnabled "$name" "$user" || $force
|
if isProgramEnabled $args || $force
|
||||||
set install true
|
set install true
|
||||||
else
|
else
|
||||||
set install false
|
set install false
|
||||||
|
|
Loading…
Reference in a new issue