Skip to content

Commit 2b57f32

Browse files
committed
(#1310) List remembered arguments
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.
1 parent 06acb28 commit 2b57f32

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/chocolatey.tests.integration/scenarios/ListScenarios.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ public void Should_contain_packages_and_versions_with_a_pipe_between_them()
140140
MockLogger.ContainsMessage("upgradepackage|1.0.0").Should().BeTrue();
141141
}
142142

143+
// Windows only because decryption fallback on Mac/Linux logs a message
143144
[Fact]
145+
[WindowsOnly]
146+
[Platform(Exclude = "Mono")]
144147
public void Should_only_have_messages_related_to_package_information()
145148
{
146149
MockLogger.Messages.Should()

src/chocolatey/infrastructure.app/services/NugetService.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ it is possible that incomplete package lists are returned from a command
183183
foreach (var pkg in NugetList.GetPackages(config, _nugetLogger, _fileSystem))
184184
{
185185
var package = pkg; // for lamda access
186+
string packageArgumentsUnencrypted = null;
186187

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

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

212217
if (!config.QuietOutput)
@@ -231,7 +236,7 @@ Package url{6}
231236
Tags: {9}
232237
Software Site: {10}
233238
Software License: {11}{12}{13}{14}{15}{16}
234-
Description: {17}{18}
239+
Description: {17}{18}{19}
235240
".FormatWith(
236241
package.Title.EscapeCurlyBraces(),
237242
package.Published.GetValueOrDefault().UtcDateTime.ToShortDateString(),
@@ -265,7 +270,8 @@ Package url{6}
265270
!string.IsNullOrWhiteSpace(package.BugTrackerUrl.ToStringSafe()) ? "{0} Issues: {1}".FormatWith(Environment.NewLine, package.BugTrackerUrl.ToStringSafe()) : string.Empty,
266271
package.Summary != null && !string.IsNullOrWhiteSpace(package.Summary.ToStringSafe()) ? "\r\n Summary: {0}".FormatWith(package.Summary.EscapeCurlyBraces().ToStringSafe()) : string.Empty,
267272
package.Description.EscapeCurlyBraces().Replace("\n ", "\n").Replace("\n", "\n "),
268-
!string.IsNullOrWhiteSpace(package.ReleaseNotes.ToStringSafe()) ? "{0} Release Notes: {1}".FormatWith(Environment.NewLine, package.ReleaseNotes.EscapeCurlyBraces().Replace("\n ", "\n").Replace("\n", "\n ")) : string.Empty
273+
!string.IsNullOrWhiteSpace(package.ReleaseNotes.ToStringSafe()) ? "{0} Release Notes: {1}".FormatWith(Environment.NewLine, package.ReleaseNotes.EscapeCurlyBraces().Replace("\n ", "\n").Replace("\n", "\n ")) : string.Empty,
274+
packageArgumentsUnencrypted != null ? packageArgumentsUnencrypted : string.Empty
269275
));
270276

271277

0 commit comments

Comments
 (0)