提交 9758131a 编写于 作者: S Sam Harwell

Update System.CommandLine to 0.1.0-alpha-63729-01

上级 f8c9b287
......@@ -11,6 +11,7 @@
<packageSources>
<clear />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="system-commandline" value="https://dotnet.myget.org/F/system-commandline/api/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
......
......@@ -162,7 +162,8 @@
<RoslynMicrosoftVisualStudioExtensionManagerVersion>0.0.4</RoslynMicrosoftVisualStudioExtensionManagerVersion>
<StreamJsonRpcVersion>1.3.23</StreamJsonRpcVersion>
<SystemCollectionsImmutableVersion>1.5.0</SystemCollectionsImmutableVersion>
<SystemCommandLineExperimentalVersion>0.1.0-alpha-63227-01</SystemCommandLineExperimentalVersion>
<SystemCommandLineExperimentalVersion>0.1.0-alpha-63729-01</SystemCommandLineExperimentalVersion>
<SystemCommandLineRenderingVersion>0.1.0-alpha-63729-01</SystemCommandLineRenderingVersion>
<SystemDrawingCommonVersion>4.5.0</SystemDrawingCommonVersion>
<SystemIOFileSystemVersion>4.3.0</SystemIOFileSystemVersion>
<SystemIOFileSystemPrimitivesVersion>4.3.0</SystemIOFileSystemPrimitivesVersion>
......
......@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.CommandLine;
using System.CommandLine.Rendering;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions.Internal;
......@@ -11,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Tools.Logging
{
internal class SimpleConsoleLogger : ILogger
{
private readonly IConsole _console;
private readonly ITerminal _terminal;
private readonly LogLevel _logLevel;
private static readonly ImmutableDictionary<LogLevel, ConsoleColor> _logLevelColorMap = new Dictionary<LogLevel, ConsoleColor>
......@@ -27,7 +28,7 @@ internal class SimpleConsoleLogger : ILogger
public SimpleConsoleLogger(IConsole console, LogLevel logLevel)
{
_console = console;
_terminal = console.GetTerminal();
_logLevel = logLevel;
}
......@@ -39,12 +40,12 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
}
var messageColor = _logLevelColorMap[logLevel];
_console.ForegroundColor = messageColor;
_terminal.ForegroundColor = messageColor;
var message = formatter(state, exception);
_console.Out.WriteLine($" {message}");
_terminal.Out.WriteLine($" {message}");
_console.ResetColor();
_terminal.ResetColor();
}
public bool IsEnabled(LogLevel logLevel)
......
......@@ -20,16 +20,15 @@ class Program
static async Task<int> Main(string[] args)
{
var parser = new CommandLineBuilder()
var parser = new CommandLineBuilder(new Command("dotnet-format", handler: CommandHandler.Create(typeof(Program).GetMethod(nameof(Run)))))
.UseParseDirective()
.UseHelp()
.UseSuggestDirective()
.UseParseErrorReporting()
.UseExceptionHandler()
.AddOption(new[] { "-w", "--workspace" }, Resources.The_solution_or_project_file_to_operate_on_If_a_file_is_not_specified_the_command_will_search_the_current_directory_for_one, a => a.WithDefaultValue(() => null).ParseArgumentsAs<string>())
.AddOption(new[] { "-v", "--verbosity" }, Resources.Set_the_verbosity_level_Allowed_values_are_quiet_minimal_normal_detailed_and_diagnostic, a => a.FromAmong(_verbosityLevels).ExactlyOne())
.AddVersionOption()
.OnExecute(typeof(Program).GetMethod(nameof(Run)))
.AddOption(new Option(new[] { "-w", "--workspace" }, Resources.The_solution_or_project_file_to_operate_on_If_a_file_is_not_specified_the_command_will_search_the_current_directory_for_one, new Argument<string>(() => null)))
.AddOption(new Option(new[] { "-v", "--verbosity" }, Resources.Set_the_verbosity_level_Allowed_values_are_quiet_minimal_normal_detailed_and_diagnostic, new Argument<string>() { Arity = ArgumentArity.ExactlyOne }.FromAmong(_verbosityLevels)))
.UseVersionOption()
.Build();
return await parser.InvokeAsync(args).ConfigureAwait(false);
......
......@@ -28,6 +28,7 @@
<ItemGroup>
<PackageReference Include="System.CommandLine.Experimental" Version="$(SystemCommandLineExperimentalVersion)" />
<PackageReference Include="System.CommandLine.Rendering" Version="$(SystemCommandLineRenderingVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
<PackageReference Include="Microsoft.VisualStudio.CodingConventions" Version="$(MicrosoftVisualStudioCodingConventionsVersion)" Publish="true" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册