From 3a5e8556c5e73a4e29a5361b7501a7d3c05717fe Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 1 Aug 2024 17:56:42 +0200 Subject: [PATCH] Add a function for getting the users to create --- scripts/Windows/Scripts/Config.ps1 | 35 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/scripts/Windows/Scripts/Config.ps1 b/scripts/Windows/Scripts/Config.ps1 index 311b13b7..2c2cc670 100644 --- a/scripts/Windows/Scripts/Config.ps1 +++ b/scripts/Windows/Scripts/Config.ps1 @@ -61,6 +61,27 @@ $null = New-Module { return $key; } + <# + .SYNOPSIS + Runs a script based on the `config.fish` script. + + .PARAMETER Script + The script to run. + #> + function Invoke-ConfigScript { + param( + [string] $Script + ) + + $scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish"; + + function fish { + wsl -- nix --extra-experimental-features "nix-command flakes" nixpkgs`#fish $args + } + + fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script" | ConvertFrom-Json; + } + <# .SYNOPSIS Gets a configuration option. @@ -73,13 +94,15 @@ $null = New-Module { [string] $Name ) - $scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish"; + Invoke-ConfigScript "getConfig $Name --json"; + } - function fish { - wsl -- nix --extra-experimental-features "nix-command flakes" nixpkgs`#fish $args - } - - fish -c ". $(ConvertTo-LinuxPath $scriptPath); getConfig $Name --json" | ConvertFrom-Json; + <# + .SYNOPSIS + Gets the names of the users to create. + #> + function Get-Users { + Invoke-ConfigScript "getUsers"; } <#