Skip to content

Commit

Permalink
feat(scoop-list): Show last-updated time (ScoopInstaller#4723)
Browse files Browse the repository at this point in the history
  • Loading branch information
rashil2000 authored Feb 9, 2022
1 parent ba970d5 commit b69bdbd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libexec/scoop-list.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ param($query)

reset_aliases
$def_arch = default_architecture
if (-not (Get-FormatData ScoopAppsList)) {
Update-FormatData "$PSScriptRoot\..\supporting\formats\ScoopAppsList.Format.ps1xml"
}

$local = installed_apps $false | ForEach-Object { @{ name = $_ } }
$global = installed_apps $true | ForEach-Object { @{ name = $_; global = $true } }
Expand All @@ -25,22 +28,26 @@ Write-Host "Installed apps$(if($query) { `" matching '$query'`"}):"
$apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object {
$app = $_.name
$global = $_.global
$item = [ordered]@{}
$item = @{ PSTypeName = 'ScoopAppsList' }
$ver = Select-CurrentVersion -AppName $app -Global:$global
$item.Name = $app
$item.Version = $ver

$install_info_path = "$(versiondir $app $ver $global)\install.json"
$updated = (Get-Item (appdir $app $global)).LastWriteTime | Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
$install_info = $null
if(Test-Path $install_info_path) {
$install_info = parse_json $install_info_path
$updated = (Get-Item $install_info_path).LastWriteTime | Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
}

$item.Source = if ($install_info.bucket) {
$install_info.bucket
} elseif ($install_info.url) {
$install_info.url
if ($install_info.url -eq (usermanifest $app)) { "<auto-generated>" }
else { $install_info.url }
}
$item.Updated = $updated

$info = @()
if($global) { $info += "Global install" }
Expand Down
34 changes: 34 additions & 0 deletions supporting/formats/ScoopAppsList.Format.ps1xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Configuration>
<ViewDefinitions>
<View>
<Name>ScoopAppsListTable</Name>
<ViewSelectedBy>
<TypeName>ScoopAppsList</TypeName>
</ViewSelectedBy>
<TableControl>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Version</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Source</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Updated</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Info</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>

0 comments on commit b69bdbd

Please sign in to comment.