@@ -569,6 +569,53 @@ class AptManager : PackageManager {
569
569
return $null
570
570
}
571
571
}
572
+ class ZypperManager : PackageManager {
573
+ ZypperManager() : base(
574
+ ' zypper' , ' zypper' , ' search' , ' install' ,
575
+ ' upgrade' , ' update' , ' search' , ' remove' , ' info' , $true
576
+ ) {
577
+ }
578
+
579
+ [Object []]AddParameters([string ]$Command , [Switch ]$Global , [Object []]$params ) {
580
+ if ($Command -imatch ' list|info' ) {
581
+ return $params
582
+ }
583
+
584
+ return $params + ' -y'
585
+ }
586
+
587
+ [ResultItem ]ParseResultItem([string ]$Line , [string ]$Command , [Switch ]$Global ) {
588
+ # golang-github-sahilm-fuzzy-dev/stable,oldstable,testing 0.1.0-1.1 all
589
+ $regex = [Regex ]::new(' ^ \|\s([^\s]+)\s+\|([^|]+)\|' )
590
+ switch - regex ($Command ){
591
+ ' list' {
592
+ $regex = [Regex ]::new(' ^i.\s\|\s([^\s]+)\s+\|([^|]+)\|' )
593
+ }
594
+ }
595
+ $ver = $null
596
+ if ($regex.IsMatch ($line )) {
597
+ $id = $regex.Match ($line ).Groups[1 ].Value.Trim()
598
+ # $ver = $regex.Match($line).Groups[2].Value.Trim()
599
+ $desc = $regex.Match ($line ).Groups[2 ].Value.Trim()
600
+ $nme = $id
601
+ $inst = ' '
602
+ switch - regex ($Command ) {
603
+ ' search' {
604
+ $inst = " $ ( $this.Install ) $id # $desc "
605
+ }
606
+ ' list' {
607
+ $inst = " $ ( $this.Uninstall ) $id # $desc "
608
+ }
609
+ }
610
+
611
+ return [ResultItem ]::new(
612
+ " sudo $ ( $this.Executable ) " , $id , $ver , $nme , $inst , $desc , $this , $Line
613
+ )
614
+ }
615
+
616
+ return $null
617
+ }
618
+ }
572
619
573
620
class HomebrewManager : PackageManager {
574
621
[string ]$Store = ' main'
@@ -1250,9 +1297,12 @@ function Invoke-Any {
1250
1297
[PackageManager ]$manager = $null
1251
1298
1252
1299
Switch - regex ($alias ) {
1253
- (' ap' ) {
1300
+ (' ap' ) {
1254
1301
$manager = [AptManager ]::new()
1255
1302
}
1303
+ (' zy' ) {
1304
+ $manager = [ZypperManager ]::new()
1305
+ }
1256
1306
(' br' ) {
1257
1307
$manager = [HomebrewManager ]::new()
1258
1308
}
@@ -1355,6 +1405,7 @@ if ($env:IsWindows -eq 'false') {
1355
1405
1356
1406
$results = @ ()
1357
1407
$aptResults = Invoke-Any $Command $Name - AllRepos - Raw:$Raw - Describe:$Describe - Exact:$Exact - Install:$Install - Global:$Global - managerCode ' ap'
1408
+ $zypperResults = Invoke-Any $Command $Name - AllRepos - Raw:$Raw - Describe:$Describe - Exact:$Exact - Install:$Install - Global:$Global - managerCode ' zy'
1358
1409
$brewResults = Invoke-Any $Command $Name - Subcommand $Subcommand - AllRepos - Raw:$Raw - Describe:$Describe - Exact:$Exact - Install:$Install - Global:$Global - managerCode ' br'
1359
1410
$snapResults = Invoke-Any $Command $Name - Subcommand $Subcommand - AllRepos - Raw:$Raw - Describe:$Describe - Exact:$Exact - Install:$Install - Global:$Global - managerCode ' sn'
1360
1411
@@ -1366,6 +1417,13 @@ if ($env:IsWindows -eq 'false') {
1366
1417
$results.Add ($aptResults )
1367
1418
}
1368
1419
1420
+ if ($zypperResults -is [ResultItem []] -or $zypperResults -is [Object []]) {
1421
+ $results.AddRange ($zypperResults )
1422
+ }
1423
+ else {
1424
+ $results.Add ($zypperResults )
1425
+ }
1426
+
1369
1427
if ($brewResults -is [ResultItem []] -or $brewResults -is [Object []]) {
1370
1428
$results.AddRange ($brewResults )
1371
1429
}
@@ -1410,7 +1468,8 @@ if ($env:IsWindows -eq 'false') {
1410
1468
Export-ModuleMember - Function Invoke-AllLinux
1411
1469
1412
1470
Set-Alias - Verbose:$Verbose - Scope Global - Description ' Snippets: [repos] apt' - Name ap - Value Invoke-Any - PassThru
1413
- Set-Alias - Verbose:$Verbose - Scope Global - Description ' Snippets: [repos] homebreq' - Name br - Value Invoke-Any - PassThru
1471
+ Set-Alias - Verbose:$Verbose - Scope Global - Description ' Snippets: [repos] zypper' - Name zy - Value Invoke-Any - PassThru
1472
+ Set-Alias - Verbose:$Verbose - Scope Global - Description ' Snippets: [repos] homebrew' - Name br - Value Invoke-Any - PassThru
1414
1473
Set-Alias - Verbose:$Verbose - Scope Global - Description ' Snippets: [repos] snap' - Name sn - Value Invoke-Any - PassThru
1415
1474
Set-Alias - Verbose:$Verbose - Scope Global - Description ' Snippets: [repos] All Repos' - Name repos - Value Invoke-AllLinux - PassThru
1416
1475
0 commit comments