Skip to content

Commit

Permalink
(chocolatey#1310) List remembered arguments
Browse files Browse the repository at this point in the history
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
  • Loading branch information
TheCakeIsNaOH committed Jul 1, 2023
1 parent d836138 commit 62b1e4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/chocolatey.tests.integration/scenarios/ListScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace chocolatey.tests.integration.scenarios
using NuGet.Configuration;
using FluentAssertions;
using FluentAssertions.Execution;
using NUnit.Framework;

public class ListScenarios
{
Expand Down Expand Up @@ -140,7 +141,10 @@ public void Should_contain_packages_and_versions_with_a_pipe_between_them()
MockLogger.ContainsMessage("upgradepackage|1.0.0").Should().BeTrue();
}

// Windows only because decryption fallback on Mac/Linux logs a message
[Fact]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public void Should_only_have_messages_related_to_package_information()
{
MockLogger.Messages.Should()
Expand Down
10 changes: 8 additions & 2 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ it is possible that incomplete package lists are returned from a command
foreach (var pkg in NugetList.GetPackages(config, _nugetLogger, _fileSystem))
{
var package = pkg; // for lamda access
string packageArgumentsUnencrypted = null;

ChocolateyPackageMetadata packageLocalMetadata;
string packageInstallLocation = null;
Expand All @@ -207,6 +208,10 @@ it is possible that incomplete package lists are returned from a command
}
}

if (!string.IsNullOrWhiteSpace(packageInfo.Arguments))
{
packageArgumentsUnencrypted = "\n Remembered Package Arguments: " + (packageInfo.Arguments.contains(" --") && packageInfo.Arguments.to_string().Length > 4 ? packageInfo.Arguments : NugetEncryptionUtility.DecryptString(packageInfo.Arguments));
}
}

if (!config.QuietOutput)
Expand All @@ -231,7 +236,7 @@ Package url{6}
Tags: {9}
Software Site: {10}
Software License: {11}{12}{13}{14}{15}{16}
Description: {17}{18}
Description: {17}{18}{19}
".FormatWith(
package.Title.EscapeCurlyBraces(),
package.Published.GetValueOrDefault().UtcDateTime.ToShortDateString(),
Expand Down Expand Up @@ -265,7 +270,8 @@ Package url{6}
!string.IsNullOrWhiteSpace(package.BugTrackerUrl.ToStringSafe()) ? "{0} Issues: {1}".FormatWith(Environment.NewLine, package.BugTrackerUrl.ToStringSafe()) : string.Empty,
package.Summary != null && !string.IsNullOrWhiteSpace(package.Summary.ToStringSafe()) ? "\r\n Summary: {0}".FormatWith(package.Summary.EscapeCurlyBraces().ToStringSafe()) : string.Empty,
package.Description.EscapeCurlyBraces().Replace("\n ", "\n").Replace("\n", "\n "),
!string.IsNullOrWhiteSpace(package.ReleaseNotes.ToStringSafe()) ? "{0} Release Notes: {1}".FormatWith(Environment.NewLine, package.ReleaseNotes.EscapeCurlyBraces().Replace("\n ", "\n").Replace("\n", "\n ")) : string.Empty
!string.IsNullOrWhiteSpace(package.ReleaseNotes.ToStringSafe()) ? "{0} Release Notes: {1}".FormatWith(Environment.NewLine, package.ReleaseNotes.EscapeCurlyBraces().Replace("\n ", "\n").Replace("\n", "\n ")) : string.Empty,
packageArgumentsUnencrypted != null ? packageArgumentsUnencrypted : string.Empty
));


Expand Down

0 comments on commit 62b1e4a

Please sign in to comment.