From b52fc4c1f9bcded2f0b95513f3e1c6a33065e3eb Mon Sep 17 00:00:00 2001 From: Zackarias Montell Date: Thu, 22 Jan 2026 10:34:57 +0100 Subject: [PATCH] Added proper flags --- requirements.ps1 | 206 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 175 insertions(+), 31 deletions(-) diff --git a/requirements.ps1 b/requirements.ps1 index 68c27f3..982120b 100644 --- a/requirements.ps1 +++ b/requirements.ps1 @@ -1,3 +1,124 @@ +param ( + [Alias('h', '?')] + [switch]$Help, + [Alias('no-winget')] + [switch]$NoWinget, + [Alias('only-winget')] + [switch]$OnlyWinget, + [Alias('install-extras')] + [switch]$Extras, + [Alias('only-extras')] + [switch]$OnlyExtras, + [Alias('no-choco')] + [switch]$NoChoco, + [Alias('only-choco')] + [switch]$OnlyChoco, + [Alias('no-powershell')] + [switch]$NoPowershell, + [Alias('only-powershell')] + [switch]$OnlyPowershell, + [Alias('no-pip')] + [switch]$NoPip, + [Alias('only-pip')] + [switch]$OnlyPip, + [Alias('no-npm')] + [switch]$NoNpm, + [Alias('only-npm')] + [switch]$OnlyNpm +) + +if ($Help) +{ + @" +requirements.ps1 – Install system requirements + +USAGE: + requirements.ps1 [options] + +OPTIONS: + -no-winget Disable installation via winget + -no-choco Disable installation via Chocolatey + -no-powershell Disable PowerShell module installation + -no-pip Disable Python pip package installation + -install-extras Install optional / extra components + -help, -h, -? Show this help message and exit + +NOTES: + • Use single-dash options for best compatibility: + -no-winget -no-choco + + • Double-dash options (--no-winget) only work in PowerShell 7+ (pwsh) + +EXAMPLES: + requirements.ps1 -no-winget -no-choco + requirements.ps1 -install-extras + pwsh requirements.ps1 --no-winget --no-pip +"@ + exit 0 +} + +function Write-Divider +{ + Write-Host "################################################################################" +} + +$Flags = [ordered]@{ + WingetEnabled = -not $NoWinget + ExtrasEnabled = $Extras + ChocoEnabled = -not $NoChoco + PowershellEnabled = -not $NoPowershell + PipEnabled = -not $NoPip + NpmEnabled = -not $NoNpm +} + +function Reset-Flags +{ + foreach ($key in @($Flags.Keys)) + { + $Flags[$key] = $false + } +} + +if ($OnlyWinget) +{ + Reset-Flags + $Flags.WingetEnabled = $true +} +if ($OnlyExtras) +{ + Reset-Flags + $Flags.ExtrasEnabled = $true +} +if ($OnlyChoco) +{ + Reset-Flags + $Flags.ChocoEnabled = $true +} +if ($OnlyPowershell) +{ + Reset-Flags + $Flags.PowershellEnabled = $true +} +if ($OnlyPip) +{ + Reset-Flags + $Flags.PipEnabled = $true +} +if ($OnlyNpm) +{ + Reset-Flags + $Flags.NpmEnabled = $true +} + +Write-Host "These providers are enabled:" +foreach ($key in $Flags.Keys) +{ + if ($Flags[$key]) + { + Write-Host $key + } +} + # Install requirements via winget # Important stuff $packages = @( @@ -18,48 +139,71 @@ $packages = @( "7zip.7zip" # nvim "rustlang.rustup" ) - -foreach ($package in $packages) -{ - winget install $package -} - -# Install latest node LTS -fnm install 22 -fnm use 22 - -cd ~ - -npm install # mostly nvim deps - -## Nvim requirements from choco, needs to be run as admin -Start-Process pwsh -Verb RunAs -ArgumentList "-Command", "choco install make unzip ripgrep zig" - -## Nvim requirements from pip -python -m pip install debugpy neovim pillow - -## Git posh -Install-Module posh-git -Scope CurrentUser -Force - -# extras, make flag for these - -$packages = @( +$ExtraPackages = @( "mRemoteNG.mRemoteNG", - "mozilla.firefox.developeredition", "Microsoft.VisualStudio.2022.Community", "JetBrains.Resharper", "Microsoft.powertoys", "spotify.spotify", "microsoft.azuredatastudio", "mozilla.thunderbird", - "yubico.authenticator", "Postman.Postman", "docker.dockerdesktop" ) -# Iterate through each package and install it -foreach ($package in $packages) +if ($Flags.WingetEnabled) { - winget install $package + Write-Divider + Write-Host "Installing Winget Packages" + foreach ($package in $packages) + { + winget install $package + } } +if ($Flags.ExtrasEnabled) +{ + Write-Divider + Write-Host "Installing Extra Winget Packages" + foreach ($package in $ExtraPackages) + { + winget install $package + } +} + +if ($Flags.NpmEnabled) +{ + Write-Divider + Write-Host "Installing Npm Packages" + fnm install 22 + fnm use 22 + Set-Location ~ + npm install +} + +if ($Flags.ChocoEnabled) +{ + Write-Divider + Write-Host "Installing Chocolatey Packages" + ## Nvim requirements from choco, needs to be run as admin + Start-Process pwsh -Verb RunAs -ArgumentList "-Command", "choco install make unzip ripgrep zig" +} + +if ($Flags.PipEnabled) +{ + Write-Divider + Write-Host "Installing pip Packages" + ## Nvim requirements from pip + python -m pip install debugpy neovim pillow +} + +if ($Flags.PowershellEnabled) +{ + Write-Divider + Write-Host "Installing Powershell Packages" + ## Git posh + Install-Module posh-git -Scope CurrentUser -Force +} + +Write-Divider +Write-Host "Done!"