Created
December 28, 2023 23:56
-
-
Save rwp0/41eacea766ccf766d1f1d9b59a17e58e to your computer and use it in GitHub Desktop.
Install My WinGet Packages (Perl script)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.38; | |
use Getopt::Long; | |
# Run as: perl winget.pl --uninstall (Perl on Windows might omit the arguments if set as default interpreter for .pl files) | |
Getopt::Long::Parser -> new -> getoptions( | |
\my %options , | |
'uninstall|u' , | |
'show|s' | |
); # Program options | |
my @packages = ( | |
'fzf' , | |
'sharkdp.bat' , | |
'jqlang.jq' # Previously: stedolan.jq | |
); # Winget packages | |
if ( defined $options{uninstall} ) { | |
uninstall( @packages ); | |
} | |
elsif ( defined $options{show} ) { | |
show( @packages ); | |
} | |
else { | |
install( @packages ); | |
} | |
sub install ( @packages ) { | |
for my $package ( @packages ) { | |
system <<~ "WINGET"; | |
winget | |
install | |
--query $package | |
--silent | |
--exact | |
--no-upgrade | |
--disable-interactivity | |
--verbose | |
WINGET | |
} | |
} | |
sub uninstall ( @packages ) { | |
for my $package ( @packages ) { | |
system <<~ "WINGET"; | |
winget | |
uninstall | |
--query $package | |
--silent | |
--exact | |
--disable-interactivity | |
--verbose | |
WINGET | |
} | |
} | |
sub show ( @packages ) { | |
for my $package ( @packages ) { | |
system <<~ "WINGET"; | |
winget | |
show | |
--query $package | |
--exact | |
--disable-interactivity | |
--verbose | |
WINGET | |
} | |
} | |
=pod | |
C<winget> comes from F<C:\Users\EAslanov\AppData\Local\Microsoft\WindowsApps\winget.exe> | |
Run C<winget install --help> for option descriptions. | |
Read more at L< https://aka.ms/winget-command-help>. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment