Skip to content

Commit

Permalink
mond install single match
Browse files Browse the repository at this point in the history
  • Loading branch information
reisir committed Oct 7, 2023
1 parent 6e7dfb1 commit 4709d4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion @Resources/MonD.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Description=Meters on Demand, the Rainmeter package manager
SkinName=Meters on Demand
LoadType=Skin
Load=Meters on Demand\Installer.ini
Version=v1.2.2
Version=v1.2.3
HeaderImage=#@#mond.bmp
Exclude=cache.json | mond.log | temp
25 changes: 18 additions & 7 deletions MetersOnDemand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ param (

# Globals
$Self = [PSCustomObject]@{
Version = "v1.2.2";
Version = "v1.2.3";
Directory = "#Mond";
FileName = "MetersOnDemand.ps1";
BatFileName = "mond.bat"
Expand Down Expand Up @@ -274,10 +274,20 @@ function Install {
$Cache,
[Parameter()]
[switch]
$Force
$Force,
[Parameter()]
[Switch]
$FirstMatch
)
if (!$Cache) { $Cache = Update-Cache }

if ($FirstMatch) {
$Matched = Search -Query $FullName -Cache $Cache -Quiet
if ($Matched.Length -gt 1) { throw "Too many results, use a more specific query" }
if ($Matched.Length -eq 0) { throw "No results" }
$FullName = $Matched[0].full_name
}

$installed = $Cache.Installed.$FullName
if ($installed -and (-not $Force)) {
return Write-Host "$($FullName) is already installed. Use -Force to reinstall." -ForegroundColor Yellow
Expand Down Expand Up @@ -585,14 +595,17 @@ function Search {
$Property,
[Parameter(Mandatory)]
[psobject]
$Cache
$Cache,
[Parameter()]
[Switch]
$Quiet
)
if (!$Query) { $Query = ".*" }
if (!$Property) { $Property = "full_name" }

if (!$Cache) { $Cache = Update-Cache }

Write-Host "Searching for `"$Query`""
if (!$Quiet) { Write-Host "Searching for `"$Query`"" }

$Results = @()
foreach ($Entry in ToIteratable -Object $Cache.Skins ) {
Expand Down Expand Up @@ -1030,9 +1043,7 @@ function Format-SkinList {

if ($Description) { Write-Host "$($_.description)" }
if ($NewLine) { Write-Host "" }

}

}

# Main body
Expand Down Expand Up @@ -1067,7 +1078,7 @@ try {
if (-not $Parameter) {
throw "Install requires the named parameter -Skin (Position = 1)"
}
Install -FullName $Parameter -Cache $Cache -Force:$Force
Install -FullName $Parameter -Cache $Cache -Force:$Force -FirstMatch
break
}
"list" {
Expand Down

0 comments on commit 4709d4e

Please sign in to comment.