From 644bf84f36e339068a0ad05c3310594e19855bd9 Mon Sep 17 00:00:00 2001 From: swaran18999 Date: Fri, 22 Aug 2025 18:09:00 -0500 Subject: [PATCH 1/3] (#1276) Add option to show last updated date in `choco list` Add `--show-last-updated-date` option to the `list` command. When enabled, this displays the last date the package was installed or updated, alongside the usual metadata fields. Previously, users had no clear indication of when a local package was last changed. This new option provides better visibility and helps with package management, especially when filtering or sorting package lists by recency. Implementation details: - Introduced new switch `show-last-updated-date`. - Logs formatted date via `package.Published` (or fallback string if unavailable). - Integrated into existing `list` command output formatting. With this change, users can more easily audit their package states and track updates over time. --- .../infrastructure.app/commands/ChocolateyListCommand.cs | 5 ++++- .../configuration/ChocolateyConfiguration.cs | 1 + src/chocolatey/infrastructure.app/services/NugetService.cs | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs index e380aca4c..22a7c6d6e 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs @@ -138,7 +138,10 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfi option => configuration.Verbose = option != null) .Add("ignore-pinned", "Ignore Pinned - Ignore pinned packages. Defaults to false.", - option => configuration.ListCommand.IgnorePinned = option != null); + option => configuration.ListCommand.IgnorePinned = option != null) + .Add("show-last-updated-date", + "Show Date - Shows the last date the package was installed/updated.", + option => configuration.ListCommand.ShowLastUpdatedDate = option != null); } public virtual int Count(ChocolateyConfiguration config) diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index c0bfe9f9c..ad0ddf704 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -626,6 +626,7 @@ public ListCommandConfiguration() public bool ByTagOnly { get; set; } public bool IdStartsWith { get; set; } public bool IgnorePinned { get; set; } + public bool ShowLastUpdatedDate { get; set; } public PackageOrder OrderBy { get; set; } [Obsolete("This property is deprecated and will be removed in version 3.0. Use the 'OrderBy' property instead.")] diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 5f5690519..a2ebbc13c 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -276,11 +276,12 @@ it is possible that incomplete package lists are returned from a command { if (!(packageInfo != null && packageInfo.IsPinned && config.ListCommand.IgnorePinned)) { - this.Log().Info(logger, () => "{0}{1}".FormatWith(package.Identity.Id, config.ListCommand.IdOnly ? string.Empty : " {0}{1}{2}{3}".FormatWith( + this.Log().Info(logger, () => "{0}{1}".FormatWith(package.Identity.Id, config.ListCommand.IdOnly ? string.Empty : " {0}{1}{2}{3} {4}".FormatWith( packageLocalMetadata != null ? packageLocalMetadata.Version.ToFullStringChecked() : package.Identity.Version.ToFullStringChecked(), package.IsApproved ? " [Approved]" : string.Empty, package.IsDownloadCacheAvailable ? " Downloads cached for licensed users" : string.Empty, - package.PackageTestResultStatus == "Failing" && package.IsDownloadCacheAvailable ? " - Possibly broken for FOSS users (due to original download location changes by vendor)" : package.PackageTestResultStatus == "Failing" ? " - Possibly broken" : string.Empty + package.PackageTestResultStatus == "Failing" && package.IsDownloadCacheAvailable ? " - Possibly broken for FOSS users (due to original download location changes by vendor)" : package.PackageTestResultStatus == "Failing" ? " - Possibly broken" : string.Empty, + config.ListCommand.ShowLastUpdatedDate ? package.Published?.ToString("yyyy-MM-dd HH:mm:ss") ?? "Last updated not available" : string.Empty )) ); From 0d400dc31bf8bfa619f69e0360e0588850e7ef00 Mon Sep 17 00:00:00 2001 From: swaran18999 Date: Mon, 22 Sep 2025 20:03:11 -0500 Subject: [PATCH 2/3] (chocolatey#1276) Add tab completion support for new list options Update `ChocolateyTabExpansion.ps1` to include the new `--show-last-updated-date` and `--order-by-last-updated-date` switches in the `list` command's tab completion options. --- src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 b/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 index cbd9fd908..d3b33b08d 100644 --- a/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 +++ b/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 @@ -49,7 +49,7 @@ $commandOptions = @{ info = "--cert='' --certpassword='' --disable-repository-optimizations --include-configured-sources --local-only --password='' --prerelease --source='' --user='' --version=''" install = "--allow-downgrade --allow-empty-checksums --allow-empty-checksums-secure --apply-args-to-dependencies --apply-package-parameters-to-dependencies --cert='' --certpassword='' --disable-repository-optimizations --download-checksum='' --download-checksum-x64='' --download-checksum-type='' --download-checksum-type-x64='' --exit-when-reboot-detected --force-dependencies --forcex86 --ignore-checksum --ignore-dependencies --ignore-detected-reboot --ignore-package-exit-codes --include-configured-sources --install-arguments='' --not-silent --override-arguments --package-parameters='' --password='' --pin --prerelease --require-checksums --skip-hooks --skip-scripts --source='' --stop-on-first-failure --use-package-exit-codes --user='' --version=''" license = "" - list = "--by-id-only --by-tag-only --detail --exact --id-only --id-starts-with --ignore-pinned --include-programs --page='' --page-size='' --prerelease --source='' --version=''" + list = "--by-id-only --by-tag-only --detail --exact --id-only --id-starts-with --ignore-pinned --include-programs --order-by-last-updated-date --page='' --page-size='' --prerelease --show-last-updated-date --source='' --version=''" new = "--automaticpackage --download-checksum='' --download-checksum-x64='' --download-checksum-type='' --maintainer='' --name='' --output-directory='' --template='' --use-built-in-template --version=''" outdated = "--cert='' --certpassword='' --disable-repository-optimizations --ignore-pinned --ignore-unfound --include-configured-sources --password='' --prerelease --source='' --user=''" pack = "--output-directory='' --version=''" From 953770796a7015e4f3d706e9d410ed5dee6e8ccd Mon Sep 17 00:00:00 2001 From: swaran18999 Date: Mon, 22 Sep 2025 20:06:01 -0500 Subject: [PATCH 3/3] (chocolatey#1276) Refactor space changes and added last update dated --- src/chocolatey/infrastructure.app/services/NugetService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index a2ebbc13c..c0c4d28b5 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -276,12 +276,12 @@ it is possible that incomplete package lists are returned from a command { if (!(packageInfo != null && packageInfo.IsPinned && config.ListCommand.IgnorePinned)) { - this.Log().Info(logger, () => "{0}{1}".FormatWith(package.Identity.Id, config.ListCommand.IdOnly ? string.Empty : " {0}{1}{2}{3} {4}".FormatWith( + this.Log().Info(logger, () => "{0}{1}".FormatWith(package.Identity.Id, config.ListCommand.IdOnly ? string.Empty : " {0}{1}{2}{3}{4}".FormatWith( packageLocalMetadata != null ? packageLocalMetadata.Version.ToFullStringChecked() : package.Identity.Version.ToFullStringChecked(), package.IsApproved ? " [Approved]" : string.Empty, package.IsDownloadCacheAvailable ? " Downloads cached for licensed users" : string.Empty, package.PackageTestResultStatus == "Failing" && package.IsDownloadCacheAvailable ? " - Possibly broken for FOSS users (due to original download location changes by vendor)" : package.PackageTestResultStatus == "Failing" ? " - Possibly broken" : string.Empty, - config.ListCommand.ShowLastUpdatedDate ? package.Published?.ToString("yyyy-MM-dd HH:mm:ss") ?? "Last updated not available" : string.Empty + config.ListCommand.ShowLastUpdatedDate ? package.Published?.ToString(" yyyy-MM-dd HH:mm:ss") ?? " Last updated not available" : string.Empty )) );