Merge branch 'master' into version-props
This commit is contained in:
commit
e644058c0e
17 changed files with 98 additions and 48 deletions
|
@ -4,8 +4,8 @@
|
||||||
<CLI_SharedFrameworkVersion>2.0.0-beta-001791-00</CLI_SharedFrameworkVersion>
|
<CLI_SharedFrameworkVersion>2.0.0-beta-001791-00</CLI_SharedFrameworkVersion>
|
||||||
<CLI_MSBuild_Version>15.2.0-preview-000047-02</CLI_MSBuild_Version>
|
<CLI_MSBuild_Version>15.2.0-preview-000047-02</CLI_MSBuild_Version>
|
||||||
<CLI_Roslyn_Version>2.0.0-rc4-61325-08</CLI_Roslyn_Version>
|
<CLI_Roslyn_Version>2.0.0-rc4-61325-08</CLI_Roslyn_Version>
|
||||||
<CLI_NETSDK_Version>2.0.0-alpha-20170322-1</CLI_NETSDK_Version>
|
<CLI_NETSDK_Version>2.0.0-alpha-20170323-1</CLI_NETSDK_Version>
|
||||||
<CLI_NuGet_Version>4.3.0-beta1-2342</CLI_NuGet_Version>
|
<CLI_NuGet_Version>4.3.0-beta1-2418</CLI_NuGet_Version>
|
||||||
<CLI_WEBSDK_Version>1.0.0-alpha-20170130-3-281</CLI_WEBSDK_Version>
|
<CLI_WEBSDK_Version>1.0.0-alpha-20170130-3-281</CLI_WEBSDK_Version>
|
||||||
<CLI_TestPlatform_Version>15.1.0-preview-20170316-05</CLI_TestPlatform_Version>
|
<CLI_TestPlatform_Version>15.1.0-preview-20170316-05</CLI_TestPlatform_Version>
|
||||||
<SharedFrameworkVersion>$(CLI_SharedFrameworkVersion)</SharedFrameworkVersion>
|
<SharedFrameworkVersion>$(CLI_SharedFrameworkVersion)</SharedFrameworkVersion>
|
||||||
|
|
|
@ -28,10 +28,17 @@ namespace Microsoft.DotNet.Archive
|
||||||
{
|
{
|
||||||
string line = $"{value.Phase} {progress}%";
|
string line = $"{value.Phase} {progress}%";
|
||||||
if (value.Phase == _currentPhase)
|
if (value.Phase == _currentPhase)
|
||||||
|
{
|
||||||
|
if (Console.IsOutputRedirected)
|
||||||
|
{
|
||||||
|
Console.Write($"...{progress}%");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Console.Write(new string('\b', _lastLineLength));
|
Console.Write(new string('\b', _lastLineLength));
|
||||||
|
|
||||||
Console.Write(line);
|
Console.Write(line);
|
||||||
|
}
|
||||||
|
|
||||||
_lastLineLength = line.Length;
|
_lastLineLength = line.Length;
|
||||||
|
|
||||||
if (progress == 100)
|
if (progress == 100)
|
||||||
|
|
|
@ -207,7 +207,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
||||||
throw new CommandParsingException(
|
throw new CommandParsingException(
|
||||||
command,
|
command,
|
||||||
"Required command missing",
|
"Required command missing",
|
||||||
isRequireSubCommandMissing: true);
|
isRequiredSubCommandMissing: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return command.Invoke();
|
return command.Invoke();
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
||||||
{
|
{
|
||||||
internal class CommandParsingException : Exception
|
internal class CommandParsingException : Exception
|
||||||
{
|
{
|
||||||
private readonly bool _isRequireSubCommandMissing;
|
private readonly bool _isRequiredSubCommandMissing;
|
||||||
|
|
||||||
public CommandParsingException(
|
public CommandParsingException(
|
||||||
string message,
|
string message,
|
||||||
|
@ -21,11 +21,11 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
||||||
public CommandParsingException(
|
public CommandParsingException(
|
||||||
CommandLineApplication command,
|
CommandLineApplication command,
|
||||||
string message,
|
string message,
|
||||||
bool isRequireSubCommandMissing = false)
|
bool isRequiredSubCommandMissing = false)
|
||||||
: this(message)
|
: this(message)
|
||||||
{
|
{
|
||||||
Command = command;
|
Command = command;
|
||||||
_isRequireSubCommandMissing = isRequireSubCommandMissing;
|
_isRequiredSubCommandMissing = isRequiredSubCommandMissing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandLineApplication Command { get; }
|
public CommandLineApplication Command { get; }
|
||||||
|
@ -36,7 +36,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _isRequireSubCommandMissing
|
return _isRequiredSubCommandMissing
|
||||||
? CommonLocalizableStrings.RequiredCommandNotPassed
|
? CommonLocalizableStrings.RequiredCommandNotPassed
|
||||||
: base.Message;
|
: base.Message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace Microsoft.DotNet.Cli
|
||||||
|
|
||||||
ParseResult = parser.ParseFrom($"dotnet {CommandName}", args);
|
ParseResult = parser.ParseFrom($"dotnet {CommandName}", args);
|
||||||
|
|
||||||
|
ParseResult.ShowHelpIfRequested();
|
||||||
|
|
||||||
var subcommandName = ParseResult.Command().Name;
|
var subcommandName = ParseResult.Command().Name;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -14,15 +14,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
|
|
||||||
public static void ShowHelpOrErrorIfAppropriate(this ParseResult parseResult)
|
public static void ShowHelpOrErrorIfAppropriate(this ParseResult parseResult)
|
||||||
{
|
{
|
||||||
var appliedCommand = parseResult.AppliedCommand();
|
parseResult.ShowHelpIfRequested();
|
||||||
|
|
||||||
if (appliedCommand.HasOption("help") ||
|
|
||||||
appliedCommand.Arguments.Contains("-?") ||
|
|
||||||
appliedCommand.Arguments.Contains("/?"))
|
|
||||||
{
|
|
||||||
// NOTE: this is a temporary stage in refactoring toward the ClicCommandLineParser being used at the CLI entry point.
|
|
||||||
throw new HelpException(parseResult.Command().HelpView());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseResult.Errors.Any())
|
if (parseResult.Errors.Any())
|
||||||
{
|
{
|
||||||
|
@ -32,5 +24,18 @@ namespace Microsoft.DotNet.Cli
|
||||||
helpText: parseResult?.Command()?.HelpView());
|
helpText: parseResult?.Command()?.HelpView());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ShowHelpIfRequested(this ParseResult parseResult)
|
||||||
|
{
|
||||||
|
var appliedCommand = parseResult.AppliedCommand();
|
||||||
|
|
||||||
|
if (appliedCommand.HasOption("help") ||
|
||||||
|
appliedCommand.Arguments.Contains("-?") ||
|
||||||
|
appliedCommand.Arguments.Contains("/?"))
|
||||||
|
{
|
||||||
|
// NOTE: this is a temporary stage in refactoring toward the ClicCommandLineParser being used at the CLI entry point.
|
||||||
|
throw new HelpException(parseResult.Command().HelpView());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,9 +2,7 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
|
||||||
|
@ -28,20 +26,14 @@ namespace Microsoft.DotNet.Cli
|
||||||
|
|
||||||
var suggestions = Suggestions(complete);
|
var suggestions = Suggestions(complete);
|
||||||
|
|
||||||
var log = new StringBuilder();
|
|
||||||
log.AppendLine($"args: {string.Join(" ", args.Select(a => $"\"{a}\""))}");
|
|
||||||
log.AppendLine("diagram: " + result.Diagram());
|
|
||||||
File.WriteAllText("parse.log", log.ToString());
|
|
||||||
|
|
||||||
foreach (var suggestion in suggestions)
|
foreach (var suggestion in suggestions)
|
||||||
{
|
{
|
||||||
Console.WriteLine(suggestion);
|
Console.WriteLine(suggestion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
File.WriteAllText("dotnet completion exception.log", e.ToString());
|
return 1;
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
foreach (var error in result.Errors)
|
foreach (var error in result.Errors)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"[{error?.Option?.Name ?? "???"}] {error.Message}");
|
Console.WriteLine($"[{error?.Option?.Name ?? "???"}] {error?.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.3.0" />
|
<PackageReference Include="Microsoft.Win32.Registry" Version="4.3.0" />
|
||||||
<PackageReference Include="Microsoft.Build" Version="$(CLI_MSBuild_Version)" />
|
<PackageReference Include="Microsoft.Build" Version="$(CLI_MSBuild_Version)" />
|
||||||
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(PlatformAbstractionsVersion)" />
|
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(PlatformAbstractionsVersion)" />
|
||||||
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-115" />
|
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-120" />
|
||||||
<PackageReference Include="Microsoft.TemplateEngine.Abstractions" Version="$(TemplateEngineVersion)" />
|
<PackageReference Include="Microsoft.TemplateEngine.Abstractions" Version="$(TemplateEngineVersion)" />
|
||||||
<PackageReference Include="Microsoft.TemplateEngine.Cli" Version="$(TemplateEngineVersion)" />
|
<PackageReference Include="Microsoft.TemplateEngine.Cli" Version="$(TemplateEngineVersion)" />
|
||||||
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects" Version="$(TemplateEngineVersion)" />
|
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects" Version="$(TemplateEngineVersion)" />
|
||||||
|
|
44
test/dotnet.Tests/GivenThatTheUserRequestsHelp.cs
Normal file
44
test/dotnet.Tests/GivenThatTheUserRequestsHelp.cs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// 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;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace dotnet.Tests
|
||||||
|
{
|
||||||
|
public class GivenThatTheUserRequestsHelp
|
||||||
|
{
|
||||||
|
[Theory]
|
||||||
|
[InlineData("-h")]
|
||||||
|
[InlineData("add -h")]
|
||||||
|
[InlineData("add package -h")]
|
||||||
|
[InlineData("add reference -h")]
|
||||||
|
[InlineData("build -h")]
|
||||||
|
[InlineData("cache -h")]
|
||||||
|
[InlineData("clean -h")]
|
||||||
|
[InlineData("list -h")]
|
||||||
|
[InlineData("migrate -h")]
|
||||||
|
[InlineData("msbuild -h")]
|
||||||
|
[InlineData("new -h")]
|
||||||
|
[InlineData("nuget -h")]
|
||||||
|
[InlineData("pack -h")]
|
||||||
|
[InlineData("publish -h")]
|
||||||
|
[InlineData("remove -h")]
|
||||||
|
[InlineData("restore -h")]
|
||||||
|
[InlineData("run -h")]
|
||||||
|
[InlineData("sln -h")]
|
||||||
|
[InlineData("sln add -h")]
|
||||||
|
[InlineData("sln list -h")]
|
||||||
|
[InlineData("sln remove -h")]
|
||||||
|
[InlineData("test -h")]
|
||||||
|
public void TheResponseIsNotAnError(string commandLine)
|
||||||
|
{
|
||||||
|
var result = new DotnetCommand()
|
||||||
|
.ExecuteWithCapturedOutput(commandLine);
|
||||||
|
|
||||||
|
result.ExitCode.Should().Be(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,6 @@
|
||||||
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
|
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
|
||||||
<PackageReference Include="xunit.netcore.extensions" Version="1.0.0-prerelease-00206" />
|
<PackageReference Include="xunit.netcore.extensions" Version="1.0.0-prerelease-00206" />
|
||||||
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(PlatformAbstractionsVersion)" />
|
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(PlatformAbstractionsVersion)" />
|
||||||
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-115" />
|
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.0-alpha-120" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue