Skip to content

Commit

Permalink
Include headers for list output
Browse files Browse the repository at this point in the history
  • Loading branch information
gep13 committed Jun 21, 2024
1 parent 4860c8e commit 427cde9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,6 @@ public virtual IEnumerable<PackageResult> List(ChocolateyConfiguration config)
// This doesn't make sense as a Debug message to me... Debug messages don't really show up when you're running normally...
this.Log().Debug(() => "Searching for package information");
}
else
{
if (config.DisplayHeaders)
{
this.Log().Info("PackageID|Version");
}
}

var packages = new List<PackageResult>();

Expand Down
22 changes: 22 additions & 0 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,28 @@ it is possible that incomplete package lists are returned from a command
{
this.Log().Debug(ChocolateyLoggers.Verbose, () => "--- Start of List ---");
}
else
{
if (config.DisplayHeaders)
{
if (config.ListCommand.IdOnly && !config.ListCommand.IncludeAlternativeSources)
{
this.Log().Info("Id");
}
else if (config.ListCommand.IdOnly && config.ListCommand.IncludeAlternativeSources)
{
this.Log().Info("Id|SourceType");
}
else if (!config.ListCommand.IdOnly && !config.ListCommand.IncludeAlternativeSources && !config.ListCommand.IncludeRegistryPrograms)
{
this.Log().Info("Id|Version");
}
else if (config.ListCommand.IncludeAlternativeSources || config.ListCommand.IncludeRegistryPrograms)
{
this.Log().Info("Id|Version|SourceType");
}
}
}

foreach (var pkg in NugetList.GetPackages(config, _nugetLogger, _fileSystem))
{
Expand Down

0 comments on commit 427cde9

Please sign in to comment.