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 authored and gep13 committed May 20, 2024
1 parent 186ffc8 commit b1b1237
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 @@ -21,6 +21,7 @@
using NuGet.Configuration;
using FluentAssertions;
using FluentAssertions.Execution;
using NUnit.Framework;

namespace chocolatey.tests.integration.scenarios
{
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 @@ -192,6 +192,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 @@ -218,6 +219,10 @@ it is possible that incomplete package lists are returned from a command
}

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

if (!config.QuietOutput)
Expand All @@ -244,7 +249,7 @@ Package url{6}
Tags: {9}
Software Site: {10}
Software License: {11}{12}{13}{14}{15}{16}
Description: {17}{18}{19}
Description: {17}{18}{19}{20}
".FormatWith(
package.Title.EscapeCurlyBraces(),
package.Published.GetValueOrDefault().UtcDateTime.ToShortDateString(),
Expand Down Expand Up @@ -279,7 +284,8 @@ Package url{6}
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(deploymentLocation) ? "{0} Deployed to: '{1}'".FormatWith(Environment.NewLine, deploymentLocation) : string.Empty
!string.IsNullOrWhiteSpace(deploymentLocation) ? "{0} Deployed to: '{1}'".FormatWith(Environment.NewLine, deploymentLocation) : string.Empty,
packageArgumentsUnencrypted != null ? packageArgumentsUnencrypted : string.Empty
));
}
}
Expand Down

0 comments on commit b1b1237

Please sign in to comment.