Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Always show full name and version when running a valid dnu subcommand #1932

Merged
merged 1 commit into from
May 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,11 @@ public void ShowHelp(string commandName = null)
}
headerBuilder.AppendLine();

var versionAndName = new StringBuilder(FullName);
if (VersionGetter != null)
{
versionAndName.Append(string.Format(" v{0}", VersionGetter()));
versionAndName.AppendLine();
}
versionAndName.AppendLine();
var nameAndVersion = new StringBuilder();
nameAndVersion.AppendLine(GetFullNameAndVersion());
nameAndVersion.AppendLine();

Console.Write("{0}{1}{2}{3}{4}", versionAndName, headerBuilder, argumentsBuilder, optionsBuilder, commandsBuilder);
Console.Write("{0}{1}{2}{3}{4}", nameAndVersion, headerBuilder, argumentsBuilder, optionsBuilder, commandsBuilder);
}

public void ShowVersion()
Expand All @@ -432,6 +428,23 @@ public void ShowVersion()
Console.WriteLine(VersionGetter());
}

public string GetFullNameAndVersion()
{
return VersionGetter == null ? FullName : string.Format("{0} v{1}", FullName, VersionGetter());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will be compiled by Mono msc compiler, which doesn't support string interpolation. So using string.Format() here

}

public void ShowRootCommandFullNameAndVersion()
{
var rootCmd = this;
while (rootCmd.Parent != null)
{
rootCmd = rootCmd.Parent;
}

Console.WriteLine(rootCmd.GetFullNameAndVersion());
Console.WriteLine();
}

private bool HasHelpCommand()
{
var helpCmd = Commands.SingleOrDefault(cmd => string.Equals("help", cmd.Name, StringComparison.OrdinalIgnoreCase));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public static void Register(CommandLineApplication cmdApp, ReportsFactory report

c.OnExecute(() =>
{
c.ShowRootCommandFullNameAndVersion();

var buildOptions = new BuildOptions();
buildOptions.OutputDir = optionOut.Value();
buildOptions.ProjectDir = argProjectDir.Value ?? Directory.GetCurrentDirectory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ private static void RegisterInstallSubcommand(CommandLineApplication commandsCmd

c.OnExecute(async () =>
{
c.ShowRootCommandFullNameAndVersion();

var feedOptions = feedCommandLineOptions.GetOptions();
var command = new InstallGlobalCommand(
appEnvironment,
Expand Down Expand Up @@ -85,6 +87,8 @@ private static void RegisterUninstallSubcommand(CommandLineApplication commandsC

c.OnExecute(() =>
{
c.ShowRootCommandFullNameAndVersion();

var command = new UninstallCommand(
AppCommandsFolderRepository.CreateDefault(),
reports: reportsFactory.CreateReports(quiet: false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public static void Register(CommandLineApplication cmdApp, ReportsFactory report

c.OnExecute(async () =>
{
c.ShowRootCommandFullNameAndVersion();

var feedOptions = feedCommandLineOptions.GetOptions();
var reports = reportsFactory.CreateReports(feedOptions.Quiet);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static void Register(CommandLineApplication cmdApp, ReportsFactory report

c.OnExecute(() =>
{
c.ShowRootCommandFullNameAndVersion();

var options = new DependencyListOptions(reportsFactory.CreateReports(verbose: true, quiet: false), argProject)
{
TargetFrameworks = frameworks.Values,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public static void Register(CommandLineApplication cmdApp, ReportsFactory report

c.OnExecute(() =>
{
c.ShowRootCommandFullNameAndVersion();

var buildOptions = new BuildOptions();
buildOptions.OutputDir = optionOut.Value();
buildOptions.ProjectDir = argProjectDir.Value ?? Directory.GetCurrentDirectory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ private static void RegisterAddSubcommand(CommandLineApplication packagesCmd, Re

c.OnExecute(async () =>
{
c.ShowRootCommandFullNameAndVersion();

var options = new AddOptions
{
Reports = reportsFactory.CreateReports(quiet: false),
Expand All @@ -68,6 +70,8 @@ private static void RegisterPushSubcommand(CommandLineApplication packagesCmd, R

c.OnExecute(() =>
{
c.ShowRootCommandFullNameAndVersion();

var reports = reportsFactory.CreateReports(quiet: false);

// Implicitly commit changes before push
Expand Down Expand Up @@ -108,6 +112,8 @@ private static void RegisterPullSubcommand(CommandLineApplication packagesCmd, R

c.OnExecute(() =>
{
c.ShowRootCommandFullNameAndVersion();

var reports = reportsFactory.CreateReports(quiet: false);

bool success;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public static void Register(CommandLineApplication cmdApp, ReportsFactory report

c.OnExecute(() =>
{
c.ShowRootCommandFullNameAndVersion();

var options = new PublishOptions
{
OutputDir = optionOut.Value(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public static void Register(CommandLineApplication cmdApp, ReportsFactory report

c.OnExecute(async () =>
{
c.ShowRootCommandFullNameAndVersion();

var feedOptions = feedCommandLineOptions.GetOptions();
var command = new RestoreCommand(applicationEnvironment);
command.Reports = reportsFactory.CreateReports(feedOptions.Quiet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public static void Register(CommandLineApplication cmdApp, ReportsFactory report

c.OnExecute(() =>
{
c.ShowRootCommandFullNameAndVersion();

var reports = reportsFactory.CreateReports(quiet: false);

var command = new WrapCommand();
Expand Down