Skip to content

Commit

Permalink
(GH-512) Display exit code for packages
Browse files Browse the repository at this point in the history
If a package is a warning or an error, display that exit code result
next to the package name.
  • Loading branch information
ferventcoder committed Apr 24, 2016
1 parent 0e9b775 commit 2272358
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfigu
this.Log().Warn(ChocolateyLoggers.Important, "Warnings:");
foreach (var warning in packageInstalls.Where(p => p.Value.Warning).or_empty_list_if_null())
{
this.Log().Warn(ChocolateyLoggers.Important, " - {0}".format_with(warning.Value.Name));
this.Log().Warn(ChocolateyLoggers.Important, " - {0}{1}".format_with(warning.Value.Name, warning.Value.ExitCode != 0 ? " (exit code {0})".format_with(warning.Value.ExitCode) : string.Empty));
}
}

Expand All @@ -381,7 +381,7 @@ public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfigu
this.Log().Error("Failures:");
foreach (var failure in packageInstalls.Where(p => !p.Value.Success).or_empty_list_if_null())
{
this.Log().Error(" - {0}".format_with(failure.Value.Name));
this.Log().Error(" - {0}{1}".format_with(failure.Value.Name, failure.Value.ExitCode != 0 ? " (exit code {0})".format_with(failure.Value.ExitCode) : string.Empty));
}
}

Expand Down Expand Up @@ -574,7 +574,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu
this.Log().Warn(ChocolateyLoggers.Important, "Warnings:");
foreach (var warning in packageUpgrades.Where(p => p.Value.Warning).or_empty_list_if_null())
{
this.Log().Warn(ChocolateyLoggers.Important, " - {0}".format_with(warning.Value.Name));
this.Log().Warn(ChocolateyLoggers.Important, " - {0}{1}".format_with(warning.Value.Name, warning.Value.ExitCode != 0 ? " (exit code {0})".format_with(warning.Value.ExitCode) : string.Empty));
}
}

Expand All @@ -583,7 +583,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu
this.Log().Error("Failures:");
foreach (var failure in packageUpgrades.Where(p => !p.Value.Success).or_empty_list_if_null())
{
this.Log().Error(" - {0}".format_with(failure.Value.Name));
this.Log().Error(" - {0}{1}".format_with(failure.Value.Name, failure.Value.ExitCode != 0 ? " (exit code {0})".format_with(failure.Value.ExitCode) : string.Empty));
}
}

Expand Down Expand Up @@ -654,7 +654,7 @@ public ConcurrentDictionary<string, PackageResult> uninstall_run(ChocolateyConfi
this.Log().Error("Failures");
foreach (var failure in packageUninstalls.Where(p => !p.Value.Success).or_empty_list_if_null())
{
this.Log().Error(" - {0}".format_with(failure.Value.Name));
this.Log().Error(" - {0}{1}".format_with(failure.Value.Name, failure.Value.ExitCode != 0 ? " (exit code {0})".format_with(failure.Value.ExitCode) : string.Empty));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/chocolatey/infrastructure/results/PackageResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public bool Warning
public string InstallLocation { get; set; }
public string Source { get; set; }
public string SourceUri { get; set; }
public int ExitCode { get; set; }

public PackageResult(IPackage package, string installLocation, string source = null) : this(package.Id.to_lower(), package.Version.to_string(), installLocation)
{
Expand Down

0 comments on commit 2272358

Please sign in to comment.