Merge pull request #6115 from jonsequitur/adaptive-help-spacing
Adaptive help spacing
This commit is contained in:
commit
960b3808ee
12 changed files with 28 additions and 36 deletions
|
@ -207,7 +207,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
|||
throw new CommandParsingException(
|
||||
command,
|
||||
"Required command missing",
|
||||
isRequireSubCommandMissing: true);
|
||||
isRequiredSubCommandMissing: true);
|
||||
}
|
||||
|
||||
return command.Invoke();
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
|||
{
|
||||
internal class CommandParsingException : Exception
|
||||
{
|
||||
private readonly bool _isRequireSubCommandMissing;
|
||||
private readonly bool _isRequiredSubCommandMissing;
|
||||
|
||||
public CommandParsingException(
|
||||
string message,
|
||||
|
@ -21,11 +21,11 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
|||
public CommandParsingException(
|
||||
CommandLineApplication command,
|
||||
string message,
|
||||
bool isRequireSubCommandMissing = false)
|
||||
bool isRequiredSubCommandMissing = false)
|
||||
: this(message)
|
||||
{
|
||||
Command = command;
|
||||
_isRequireSubCommandMissing = isRequireSubCommandMissing;
|
||||
_isRequiredSubCommandMissing = isRequiredSubCommandMissing;
|
||||
}
|
||||
|
||||
public CommandLineApplication Command { get; }
|
||||
|
@ -36,7 +36,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
|
|||
{
|
||||
get
|
||||
{
|
||||
return _isRequireSubCommandMissing
|
||||
return _isRequiredSubCommandMissing
|
||||
? CommonLocalizableStrings.RequiredCommandNotPassed
|
||||
: base.Message;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
|
@ -28,20 +26,14 @@ namespace Microsoft.DotNet.Cli
|
|||
|
||||
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)
|
||||
{
|
||||
Console.WriteLine(suggestion);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
File.WriteAllText("dotnet completion exception.log", e.ToString());
|
||||
throw;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Microsoft.DotNet.Cli
|
|||
Console.WriteLine();
|
||||
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.Build" Version="$(CLI_MSBuild_Version)" />
|
||||
<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.Cli" Version="$(TemplateEngineVersion)" />
|
||||
<PackageReference Include="Microsoft.TemplateEngine.Orchestrator.RunnableProjects" Version="$(TemplateEngineVersion)" />
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace Microsoft.DotNet.Cli.Add.Reference.Tests
|
|||
Usage: dotnet add <PROJECT> reference [options] <args>
|
||||
|
||||
Arguments:
|
||||
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
|
||||
<args> Project to project references to add
|
||||
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
|
||||
<args> Project to project references to add
|
||||
|
||||
Options:
|
||||
-h, --help Show help information
|
||||
-f, --framework <FRAMEWORK> Add reference only when targeting a specific framework
|
||||
-h, --help Show help information
|
||||
-f, --framework <FRAMEWORK> Add reference only when targeting a specific framework
|
||||
";
|
||||
|
||||
const string FrameworkNet451Arg = "-f net451";
|
||||
|
|
|
@ -18,10 +18,10 @@ namespace Microsoft.DotNet.Cli.List.Reference.Tests
|
|||
Usage: dotnet list <PROJECT> reference [options]
|
||||
|
||||
Arguments:
|
||||
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
|
||||
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
|
||||
|
||||
Options:
|
||||
-h, --help Show help information
|
||||
-h, --help Show help information
|
||||
";
|
||||
|
||||
const string FrameworkNet451Arg = "-f net451";
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace Microsoft.DotNet.Cli.Remove.Reference.Tests
|
|||
Usage: dotnet remove <PROJECT> reference [options] <args>
|
||||
|
||||
Arguments:
|
||||
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
|
||||
<args> Project to project references to remove
|
||||
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
|
||||
<args> Project to project references to remove
|
||||
|
||||
Options:
|
||||
-h, --help Show help information
|
||||
-f, --framework <FRAMEWORK> Remove reference only when targeting a specific framework
|
||||
-h, --help Show help information
|
||||
-f, --framework <FRAMEWORK> Remove reference only when targeting a specific framework
|
||||
";
|
||||
|
||||
const string FrameworkNet451Arg = "-f net451";
|
||||
|
|
|
@ -20,11 +20,11 @@ namespace Microsoft.DotNet.Cli.Sln.Add.Tests
|
|||
Usage: dotnet sln <SLN_FILE> add [options] <args>
|
||||
|
||||
Arguments:
|
||||
<SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
|
||||
<args> Add one or more specified projects to the solution.
|
||||
<SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
|
||||
<args> Add one or more specified projects to the solution.
|
||||
|
||||
Options:
|
||||
-h, --help Show help information
|
||||
-h, --help Show help information
|
||||
";
|
||||
private ITestOutputHelper _output;
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ namespace Microsoft.DotNet.Cli.Sln.List.Tests
|
|||
Usage: dotnet sln <SLN_FILE> list [options]
|
||||
|
||||
Arguments:
|
||||
<SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
|
||||
<SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
|
||||
|
||||
Options:
|
||||
-h, --help Show help information
|
||||
-h, --help Show help information
|
||||
";
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -18,11 +18,11 @@ namespace Microsoft.DotNet.Cli.Sln.Remove.Tests
|
|||
Usage: dotnet sln <SLN_FILE> remove [options] <args>
|
||||
|
||||
Arguments:
|
||||
<SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
|
||||
<args> Remove the specified project(s) from the solution. The project is not impacted.
|
||||
<SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
|
||||
<args> Remove the specified project(s) from the solution. The project is not impacted.
|
||||
|
||||
Options:
|
||||
-h, --help Show help information
|
||||
-h, --help Show help information
|
||||
";
|
||||
|
||||
private const string ExpectedSlnContentsAfterRemove = @"
|
||||
|
|
|
@ -42,6 +42,6 @@
|
|||
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
|
||||
<PackageReference Include="xunit.netcore.extensions" Version="1.0.0-prerelease-00206" />
|
||||
<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>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in a new issue