#!/bin/env fish
begin
    set -l dir (status dirname)
    source "$dir/../../../lib/software.fish"

    function configureSW -V dir
        source "$dir/../../../lib/settings.fish"
        set config (getProgramConfig $argv --json)

        for name in (echo "$config" | jq '.networkFiles | keys[]' --raw-output0 | string split0 || true)
            echo "$config" | NAME=$name jq '.networkFiles[env.NAME]' --raw-output | sudo tee "/etc/systemd/network/10-$name.network" >/dev/null
        end
    end

    runInstaller $argv
end