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 Jan 28, 2023
1 parent c6e30b7 commit 039142a
Showing 1 changed file with 8 additions and 2 deletions.
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 @@ -160,6 +160,7 @@ public virtual IEnumerable<PackageResult> list_run(ChocolateyConfiguration confi
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 @@ -184,6 +185,10 @@ public virtual IEnumerable<PackageResult> list_run(ChocolateyConfiguration confi
}
}

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 @@ -208,7 +213,7 @@ Package url{6}
Tags: {9}
Software Site: {10}
Software License: {11}{12}{13}{14}{15}{16}
Description: {17}{18}
Description: {17}{18}{19}
".format_with(
package.Title.escape_curly_braces(),
package.Published.GetValueOrDefault().UtcDateTime.ToShortDateString(),
Expand Down Expand Up @@ -242,7 +247,8 @@ Package url{6}
!string.IsNullOrWhiteSpace(package.BugTrackerUrl.to_string()) ? "{0} Issues: {1}".format_with(Environment.NewLine, package.BugTrackerUrl.to_string()) : string.Empty,
package.Summary != null && !string.IsNullOrWhiteSpace(package.Summary.to_string()) ? "\r\n Summary: {0}".format_with(package.Summary.escape_curly_braces().to_string()) : string.Empty,
package.Description.escape_curly_braces().Replace("\n ", "\n").Replace("\n", "\n "),
!string.IsNullOrWhiteSpace(package.ReleaseNotes.to_string()) ? "{0} Release Notes: {1}".format_with(Environment.NewLine, package.ReleaseNotes.escape_curly_braces().Replace("\n ", "\n").Replace("\n", "\n ")) : string.Empty
!string.IsNullOrWhiteSpace(package.ReleaseNotes.to_string()) ? "{0} Release Notes: {1}".format_with(Environment.NewLine, package.ReleaseNotes.escape_curly_braces().Replace("\n ", "\n").Replace("\n", "\n ")) : string.Empty,
packageArgumentsUnencrypted != null ? packageArgumentsUnencrypted : string.Empty
));


Expand Down

0 comments on commit 039142a

Please sign in to comment.