2016-02-04 12:41:50 -08:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tools.Help
|
|
|
|
|
{
|
|
|
|
|
public class HelpCommand
|
|
|
|
|
{
|
|
|
|
|
private const string ProductLongName = ".NET Command Line Tools";
|
|
|
|
|
private const string UsageText = @"Usage: dotnet [common-options] [command] [arguments]
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
[command] The command to execute
|
|
|
|
|
[arguments] Arguments to pass to the command
|
|
|
|
|
|
|
|
|
|
Common Options (passed before the command):
|
|
|
|
|
-v|--verbose Enable verbose output
|
2016-03-24 15:36:58 -05:00
|
|
|
|
--version Display .NET CLI Version Number
|
|
|
|
|
--info Display .NET CLI Info
|
2016-02-04 12:41:50 -08:00
|
|
|
|
|
|
|
|
|
Common Commands:
|
|
|
|
|
new Initialize a basic .NET project
|
|
|
|
|
restore Restore dependencies specified in the .NET project
|
|
|
|
|
build Builds a .NET project
|
|
|
|
|
publish Publishes a .NET project for deployment (including the runtime)
|
|
|
|
|
run Compiles and immediately executes a .NET project
|
2016-03-25 21:13:22 -07:00
|
|
|
|
test Executes tests in a test project
|
2016-02-04 12:41:50 -08:00
|
|
|
|
repl Launch an interactive session (read, eval, print, loop)
|
|
|
|
|
pack Creates a NuGet package";
|
2016-02-18 01:09:23 -08:00
|
|
|
|
public static readonly string ProductVersion = GetProductVersion();
|
2016-02-04 12:41:50 -08:00
|
|
|
|
|
|
|
|
|
private static string GetProductVersion()
|
|
|
|
|
{
|
|
|
|
|
var attr = typeof(HelpCommand).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
|
|
|
|
return attr?.InformationalVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int Run(string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
PrintHelp();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return Cli.Program.Main(new[] { args[0], "--help" });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void PrintHelp()
|
|
|
|
|
{
|
|
|
|
|
PrintVersionHeader();
|
|
|
|
|
Reporter.Output.WriteLine(UsageText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void PrintVersionHeader()
|
|
|
|
|
{
|
|
|
|
|
var versionString = string.IsNullOrEmpty(ProductVersion) ?
|
|
|
|
|
string.Empty :
|
|
|
|
|
$" ({ProductVersion})";
|
|
|
|
|
Reporter.Output.WriteLine(ProductLongName + versionString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|