Add function for configuring user settings

This commit is contained in:
Manuel Thalmann 2024-07-20 03:50:38 +02:00
parent f0d4e900ba
commit 7560191834
3 changed files with 26 additions and 2 deletions

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../Scripts/config.fish" source "$dir/../Scripts/config.fish"
set -l users (getConfig valhalla.users --apply "builtins.attrNames" --json) set -l users (getUsers)
for name in (echo "$users" | jq '.[]' --raw-output0 | string split0) for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)

View file

@ -4,6 +4,10 @@ function getConfig -S -a property
evalModule "$CONFIG_MODULE" "$property" $argv[2..] evalModule "$CONFIG_MODULE" "$property" $argv[2..]
end end
function getUsers -S
getConfig valhalla.users --apply "builtins.attrNames" --json
end
function isSet -S -a property function isSet -S -a property
not test "$(getConfig "$property" --json)" = "null" not test "$(getConfig "$property" --json)" = "null"
end end

View file

@ -1,16 +1,36 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname)
function installSW function installSW
end end
function configureSW function configureSW
end end
function runInstaller -a action function userConfig -a user
end
function runInstaller -V dir -a action
if [ -z "$action" ] || [ "$action" = "install" ] if [ -z "$action" ] || [ "$action" = "install" ]
installSW $argv[2..] installSW $argv[2..]
else if [ "$action" = "configure" ] else if [ "$action" = "configure" ]
configureSW $argv[2..] configureSW $argv[2..]
source "$dir/config.fish"
set -l users (getUsers)
for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)
runInstaller userConfig "$name"
end
else if [ "$action" = "userConfig" ]
set -l name $argv[2]
if [ -z "$name" ]
set name "$USER"
end
userConfig "$name" $argv[3..]
end end
end end
end end