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

Commit

Permalink
Always show full name and version when running a valid dnu subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengTian committed May 22, 2015
1 parent 4bb7649 commit ba529cb
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 8 deletions.
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());
}

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 @@ -79,6 +81,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

0 comments on commit ba529cb

Please sign in to comment.