mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 17:02:51 +08:00
parent
913a7b1e37
commit
a23bec4082
@ -6,7 +6,7 @@ namespace ColorExample
|
|||||||
{
|
{
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
if (AnsiConsole.Capabilities.ColorSystem == ColorSystem.NoColors)
|
if (AnsiConsole.Profile.ColorSystem == ColorSystem.NoColors)
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// No colors
|
// No colors
|
||||||
@ -16,7 +16,7 @@ namespace ColorExample
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AnsiConsole.Capabilities.Supports(ColorSystem.Legacy))
|
if (AnsiConsole.Profile.Supports(ColorSystem.Legacy))
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// 3-BIT
|
// 3-BIT
|
||||||
@ -39,7 +39,7 @@ namespace ColorExample
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AnsiConsole.Capabilities.Supports(ColorSystem.Standard))
|
if (AnsiConsole.Profile.Supports(ColorSystem.Standard))
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// 4-BIT
|
// 4-BIT
|
||||||
@ -62,7 +62,7 @@ namespace ColorExample
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AnsiConsole.Capabilities.Supports(ColorSystem.EightBit))
|
if (AnsiConsole.Profile.Supports(ColorSystem.EightBit))
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// 8-BIT
|
// 8-BIT
|
||||||
@ -89,7 +89,7 @@ namespace ColorExample
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AnsiConsole.Capabilities.Supports(ColorSystem.TrueColor))
|
if (AnsiConsole.Profile.Supports(ColorSystem.TrueColor))
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// 24-BIT
|
// 24-BIT
|
||||||
|
@ -9,12 +9,16 @@ namespace InfoExample
|
|||||||
var grid = new Grid()
|
var grid = new Grid()
|
||||||
.AddColumn(new GridColumn().NoWrap().PadRight(4))
|
.AddColumn(new GridColumn().NoWrap().PadRight(4))
|
||||||
.AddColumn()
|
.AddColumn()
|
||||||
.AddRow("[b]Color system[/]", $"{AnsiConsole.Capabilities.ColorSystem}")
|
.AddRow("[b]Profile[/]", $"{AnsiConsole.Console.Profile.Name}")
|
||||||
.AddRow("[b]Supports ansi?[/]", $"{YesNo(AnsiConsole.Capabilities.SupportsAnsi)}")
|
.AddRow("[b]Color system[/]", $"{AnsiConsole.Profile.ColorSystem}")
|
||||||
.AddRow("[b]Legacy console?[/]", $"{YesNo(AnsiConsole.Capabilities.LegacyConsole)}")
|
.AddRow("[b]Supports ansi?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Ansi)}")
|
||||||
.AddRow("[b]Interactive?[/]", $"{YesNo(AnsiConsole.Capabilities.SupportsInteraction)}")
|
.AddRow("[b]Supports links?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Links)}")
|
||||||
.AddRow("[b]Buffer width[/]", $"{AnsiConsole.Console.Width}")
|
.AddRow("[b]Legacy console?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Legacy)}")
|
||||||
.AddRow("[b]Buffer height[/]", $"{AnsiConsole.Console.Height}");
|
.AddRow("[b]Interactive?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Interactive)}")
|
||||||
|
.AddRow("[b]TTY?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Tty)}")
|
||||||
|
.AddRow("[b]Buffer width[/]", $"{AnsiConsole.Console.Profile.Width}")
|
||||||
|
.AddRow("[b]Buffer height[/]", $"{AnsiConsole.Console.Profile.Height}")
|
||||||
|
.AddRow("[b]Encoding[/]", $"{AnsiConsole.Console.Profile.Encoding.EncodingName}");
|
||||||
|
|
||||||
AnsiConsole.Render(
|
AnsiConsole.Render(
|
||||||
new Panel(grid)
|
new Panel(grid)
|
||||||
|
@ -6,7 +6,7 @@ namespace LinkExample
|
|||||||
{
|
{
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
if (AnsiConsole.Capabilities.SupportLinks)
|
if (AnsiConsole.Profile.Capabilities.Links)
|
||||||
{
|
{
|
||||||
AnsiConsole.MarkupLine("[link=https://patriksvensson.se]Click to visit my blog[/]!");
|
AnsiConsole.MarkupLine("[link=https://patriksvensson.se]Click to visit my blog[/]!");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace Cursor
|
|||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
// Check if we can accept key strokes
|
// Check if we can accept key strokes
|
||||||
if (!AnsiConsole.Capabilities.SupportsInteraction)
|
if (!AnsiConsole.Profile.Capabilities.Interactive)
|
||||||
{
|
{
|
||||||
AnsiConsole.MarkupLine("[red]Environment does not support interaction.[/]");
|
AnsiConsole.MarkupLine("[red]Environment does not support interaction.[/]");
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Testing
|
namespace Spectre.Console.Testing
|
||||||
@ -13,10 +12,7 @@ namespace Spectre.Console.Testing
|
|||||||
|
|
||||||
public string Output => _writer.ToString();
|
public string Output => _writer.ToString();
|
||||||
|
|
||||||
public Capabilities Capabilities => _console.Capabilities;
|
public Profile Profile => _console.Profile;
|
||||||
public Encoding Encoding => _console.Encoding;
|
|
||||||
public int Width { get; }
|
|
||||||
public int Height => _console.Height;
|
|
||||||
public IAnsiConsoleCursor Cursor => _console.Cursor;
|
public IAnsiConsoleCursor Cursor => _console.Cursor;
|
||||||
public FakeConsoleInput Input { get; }
|
public FakeConsoleInput Input { get; }
|
||||||
public RenderPipeline Pipeline => _console.Pipeline;
|
public RenderPipeline Pipeline => _console.Pipeline;
|
||||||
@ -24,21 +20,22 @@ namespace Spectre.Console.Testing
|
|||||||
IAnsiConsoleInput IAnsiConsole.Input => Input;
|
IAnsiConsoleInput IAnsiConsole.Input => Input;
|
||||||
|
|
||||||
public FakeAnsiConsole(
|
public FakeAnsiConsole(
|
||||||
ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes,
|
ColorSystem system,
|
||||||
InteractionSupport interaction = InteractionSupport.Yes,
|
AnsiSupport ansi = AnsiSupport.Yes,
|
||||||
int width = 80)
|
int width = 80)
|
||||||
{
|
{
|
||||||
_writer = new StringWriter();
|
_writer = new StringWriter();
|
||||||
_console = AnsiConsole.Create(new AnsiConsoleSettings
|
|
||||||
|
var factory = AnsiConsoleFactory.NoEnrichers();
|
||||||
|
_console = factory.Create(new AnsiConsoleSettings
|
||||||
{
|
{
|
||||||
Ansi = ansi,
|
Ansi = ansi,
|
||||||
ColorSystem = (ColorSystemSupport)system,
|
ColorSystem = (ColorSystemSupport)system,
|
||||||
Interactive = interaction,
|
|
||||||
Out = _writer,
|
Out = _writer,
|
||||||
LinkIdentityGenerator = new FakeLinkIdentityGenerator(1024),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Width = width;
|
_console.Profile.Width = width;
|
||||||
|
|
||||||
Input = new FakeConsoleInput();
|
Input = new FakeConsoleInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,14 +9,10 @@ namespace Spectre.Console.Testing
|
|||||||
{
|
{
|
||||||
public sealed class FakeConsole : IAnsiConsole, IDisposable
|
public sealed class FakeConsole : IAnsiConsole, IDisposable
|
||||||
{
|
{
|
||||||
public Capabilities Capabilities { get; }
|
public Profile Profile { get; }
|
||||||
public Encoding Encoding { get; }
|
|
||||||
public IAnsiConsoleCursor Cursor => new FakeAnsiConsoleCursor();
|
public IAnsiConsoleCursor Cursor => new FakeAnsiConsoleCursor();
|
||||||
public FakeConsoleInput Input { get; }
|
public FakeConsoleInput Input { get; }
|
||||||
|
|
||||||
public int Width { get; }
|
|
||||||
public int Height { get; }
|
|
||||||
|
|
||||||
IAnsiConsoleInput IAnsiConsole.Input => Input;
|
IAnsiConsoleInput IAnsiConsole.Input => Input;
|
||||||
public RenderPipeline Pipeline { get; }
|
public RenderPipeline Pipeline { get; }
|
||||||
|
|
||||||
@ -34,13 +30,18 @@ namespace Spectre.Console.Testing
|
|||||||
bool supportsAnsi = true, ColorSystem colorSystem = ColorSystem.Standard,
|
bool supportsAnsi = true, ColorSystem colorSystem = ColorSystem.Standard,
|
||||||
bool legacyConsole = false, bool interactive = true)
|
bool legacyConsole = false, bool interactive = true)
|
||||||
{
|
{
|
||||||
Capabilities = new Capabilities(supportsAnsi, colorSystem, legacyConsole, interactive);
|
|
||||||
Encoding = encoding ?? Encoding.UTF8;
|
|
||||||
Width = width;
|
|
||||||
Height = height;
|
|
||||||
Writer = new StringWriter();
|
Writer = new StringWriter();
|
||||||
Input = new FakeConsoleInput();
|
Input = new FakeConsoleInput();
|
||||||
Pipeline = new RenderPipeline();
|
Pipeline = new RenderPipeline();
|
||||||
|
|
||||||
|
Profile = new Profile("Fake console", Writer, encoding ?? Encoding.UTF8);
|
||||||
|
Profile.Width = width;
|
||||||
|
Profile.Height = height;
|
||||||
|
Profile.ColorSystem = colorSystem;
|
||||||
|
Profile.Capabilities.Ansi = supportsAnsi;
|
||||||
|
Profile.Capabilities.Legacy = legacyConsole;
|
||||||
|
Profile.Capabilities.Interactive = interactive;
|
||||||
|
Profile.Capabilities.Links = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
namespace Spectre.Console.Testing
|
|
||||||
{
|
|
||||||
public sealed class FakeLinkIdentityGenerator : ILinkIdentityGenerator
|
|
||||||
{
|
|
||||||
private readonly int _linkId;
|
|
||||||
|
|
||||||
public FakeLinkIdentityGenerator(int linkId)
|
|
||||||
{
|
|
||||||
_linkId = linkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GenerateId(string link, string text)
|
|
||||||
{
|
|
||||||
return _linkId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +1,5 @@
|
|||||||
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Tests
|
namespace Spectre.Console.Tests
|
||||||
{
|
{
|
||||||
public static class Constants
|
public static class Constants
|
||||||
@ -5,15 +7,15 @@ namespace Spectre.Console.Tests
|
|||||||
public static string[] VersionCommand { get; } =
|
public static string[] VersionCommand { get; } =
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
Spectre.Console.Cli.Internal.Constants.Commands.Branch,
|
CliConstants.Commands.Branch,
|
||||||
Spectre.Console.Cli.Internal.Constants.Commands.Version,
|
CliConstants.Commands.Version,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string[] XmlDocCommand { get; } =
|
public static string[] XmlDocCommand { get; } =
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
Spectre.Console.Cli.Internal.Constants.Commands.Branch,
|
CliConstants.Commands.Branch,
|
||||||
Spectre.Console.Cli.Internal.Constants.Commands.XmlDoc,
|
CliConstants.Commands.XmlDoc,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
|
|
||||||
namespace Spectre.Console.Tests.Data
|
namespace Spectre.Console.Tests.Data
|
||||||
{
|
{
|
||||||
public static class TestExceptions
|
public static class TestExceptions
|
||||||
{
|
{
|
||||||
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "<Pending>")]
|
|
||||||
public static bool MethodThatThrows(int? number) => throw new InvalidOperationException("Throwing!");
|
public static bool MethodThatThrows(int? number) => throw new InvalidOperationException("Throwing!");
|
||||||
|
|
||||||
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "<Pending>")]
|
|
||||||
public static bool GenericMethodThatThrows<T0, T1, TRet>(int? number) => throw new InvalidOperationException("Throwing!");
|
public static bool GenericMethodThatThrows<T0, T1, TRet>(int? number) => throw new InvalidOperationException("Throwing!");
|
||||||
|
|
||||||
public static void ThrowWithInnerException()
|
public static void ThrowWithInnerException()
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Tests.Data
|
namespace Spectre.Console.Tests.Data
|
||||||
@ -6,7 +5,6 @@ namespace Spectre.Console.Tests.Data
|
|||||||
public class ArgumentVectorSettings : CommandSettings
|
public class ArgumentVectorSettings : CommandSettings
|
||||||
{
|
{
|
||||||
[CommandArgument(0, "<Foos>")]
|
[CommandArgument(0, "<Foos>")]
|
||||||
[SuppressMessage("Performance", "CA1819:Properties should not return arrays")]
|
|
||||||
public string[] Foo { get; set; }
|
public string[] Foo { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Tests.Data
|
namespace Spectre.Console.Tests.Data
|
||||||
@ -6,18 +5,15 @@ namespace Spectre.Console.Tests.Data
|
|||||||
public class MultipleArgumentVectorSettings : CommandSettings
|
public class MultipleArgumentVectorSettings : CommandSettings
|
||||||
{
|
{
|
||||||
[CommandArgument(0, "<Foos>")]
|
[CommandArgument(0, "<Foos>")]
|
||||||
[SuppressMessage("Performance", "CA1819:Properties should not return arrays")]
|
|
||||||
public string[] Foo { get; set; }
|
public string[] Foo { get; set; }
|
||||||
|
|
||||||
[CommandArgument(0, "<Bars>")]
|
[CommandArgument(0, "<Bars>")]
|
||||||
[SuppressMessage("Performance", "CA1819:Properties should not return arrays")]
|
|
||||||
public string[] Bar { get; set; }
|
public string[] Bar { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MultipleArgumentVectorSpecifiedFirstSettings : CommandSettings
|
public class MultipleArgumentVectorSpecifiedFirstSettings : CommandSettings
|
||||||
{
|
{
|
||||||
[CommandArgument(0, "<Foos>")]
|
[CommandArgument(0, "<Foos>")]
|
||||||
[SuppressMessage("Performance", "CA1819:Properties should not return arrays")]
|
|
||||||
public string[] Foo { get; set; }
|
public string[] Foo { get; set; }
|
||||||
|
|
||||||
[CommandArgument(1, "<Bar>")]
|
[CommandArgument(1, "<Bar>")]
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Spectre.Console.Tests.Data
|
namespace Spectre.Console.Tests.Data
|
||||||
@ -6,11 +5,9 @@ namespace Spectre.Console.Tests.Data
|
|||||||
public class OptionVectorSettings : CommandSettings
|
public class OptionVectorSettings : CommandSettings
|
||||||
{
|
{
|
||||||
[CommandOption("--foo")]
|
[CommandOption("--foo")]
|
||||||
[SuppressMessage("Performance", "CA1819:Properties should not return arrays")]
|
|
||||||
public string[] Foo { get; set; }
|
public string[] Foo { get; set; }
|
||||||
|
|
||||||
[CommandOption("--bar")]
|
[CommandOption("--bar")]
|
||||||
[SuppressMessage("Performance", "CA1819:Properties should not return arrays")]
|
|
||||||
public int[] Bar { get; set; }
|
public int[] Bar { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,3 @@
|
|||||||
<ProjectConfiguration>
|
<ProjectConfiguration>
|
||||||
<Settings>
|
<Settings />
|
||||||
<IgnoredTests>
|
|
||||||
<NamedTestSelector>
|
|
||||||
<TestName>Spectre.Console.Tests.Unit.Cli.CommandAppTests+Parsing+UnknownCommand.Should_Return_Correct_Text_With_Suggestion_And_No_Arguments_When_Root_Command_Is_Unknown_And_Distance_Is_Small</TestName>
|
|
||||||
</NamedTestSelector>
|
|
||||||
<NamedTestSelector>
|
|
||||||
<TestName>Spectre.Console.Tests.Unit.Cli.CommandAppTests+Parsing+UnknownCommand.Should_Return_Correct_Text_With_Suggestion_When_Command_Followed_By_Argument_Is_Unknown_And_Distance_Is_Small</TestName>
|
|
||||||
</NamedTestSelector>
|
|
||||||
<NamedTestSelector>
|
|
||||||
<TestName>Spectre.Console.Tests.Unit.Cli.CommandAppTests+Parsing+UnknownCommand.Should_Return_Correct_Text_With_Suggestion_When_Root_Command_After_Argument_Is_Unknown_And_Distance_Is_Small</TestName>
|
|
||||||
</NamedTestSelector>
|
|
||||||
<NamedTestSelector>
|
|
||||||
<TestName>Spectre.Console.Tests.Unit.Cli.CommandAppTests+Parsing+UnknownCommand.Should_Return_Correct_Text_With_Suggestion_When_Root_Command_Followed_By_Argument_Is_Unknown_And_Distance_Is_Small</TestName>
|
|
||||||
</NamedTestSelector>
|
|
||||||
</IgnoredTests>
|
|
||||||
</Settings>
|
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using Spectre.Console.Testing;
|
using Spectre.Console.Testing;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@ -8,14 +7,11 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
{
|
{
|
||||||
public partial class AnsiConsoleTests
|
public partial class AnsiConsoleTests
|
||||||
{
|
{
|
||||||
[SuppressMessage("Naming", "CA1724:Type names should not match namespaces")]
|
|
||||||
public sealed class Markup
|
public sealed class Markup
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("[yellow]Hello[/]", "[93mHello[0m")]
|
[InlineData("[yellow]Hello[/]", "[93mHello[0m")]
|
||||||
[InlineData("[yellow]Hello [italic]World[/]![/]", "[93mHello [0m[3;93mWorld[0m[93m![0m")]
|
[InlineData("[yellow]Hello [italic]World[/]![/]", "[93mHello [0m[3;93mWorld[0m[93m![0m")]
|
||||||
[InlineData("[link=https://patriksvensson.se]Click to visit my blog[/]", "]8;id=1024;https://patriksvensson.se\\Click to visit my blog]8;;\\")]
|
|
||||||
[InlineData("[link]https://patriksvensson.se[/]", "]8;id=1024;https://patriksvensson.se\\https://patriksvensson.se]8;;\\")]
|
|
||||||
public void Should_Output_Expected_Ansi_For_Markup(string markup, string expected)
|
public void Should_Output_Expected_Ansi_For_Markup(string markup, string expected)
|
||||||
{
|
{
|
||||||
// Given
|
// Given
|
||||||
@ -28,6 +24,32 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Output.ShouldBe(expected);
|
console.Output.ShouldBe(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Should_Output_Expected_Ansi_For_Link_With_Url_And_Text()
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
var console = new FakeAnsiConsole(ColorSystem.Standard, AnsiSupport.Yes);
|
||||||
|
|
||||||
|
// When
|
||||||
|
console.Markup("[link=https://patriksvensson.se]Click to visit my blog[/]");
|
||||||
|
|
||||||
|
// Then
|
||||||
|
console.Output.ShouldMatch("]8;id=[0-9]*;https:\\/\\/patriksvensson\\.se\\\\Click to visit my blog]8;;\\\\");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Should_Output_Expected_Ansi_For_Link_With_Only_Url()
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
var console = new FakeAnsiConsole(ColorSystem.Standard, AnsiSupport.Yes);
|
||||||
|
|
||||||
|
// When
|
||||||
|
console.Markup("[link]https://patriksvensson.se[/]");
|
||||||
|
|
||||||
|
// Then
|
||||||
|
console.Output.ShouldMatch("]8;id=[0-9]*;https:\\/\\/patriksvensson\\.se\\\\https:\\/\\/patriksvensson\\.se]8;;\\\\");
|
||||||
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("[yellow]Hello [[ World[/]", "[93mHello [ World[0m")]
|
[InlineData("[yellow]Hello [[ World[/]", "[93mHello [ World[0m")]
|
||||||
public void Should_Be_Able_To_Escape_Tags(string markup, string expected)
|
public void Should_Be_Able_To_Escape_Tags(string markup, string expected)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Internal;
|
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console
|
||||||
{
|
{
|
||||||
@ -16,6 +15,7 @@ namespace Spectre.Console
|
|||||||
ColorSystem = ColorSystemSupport.Detect,
|
ColorSystem = ColorSystemSupport.Detect,
|
||||||
Out = System.Console.Out,
|
Out = System.Console.Out,
|
||||||
});
|
});
|
||||||
|
|
||||||
Created = true;
|
Created = true;
|
||||||
return console;
|
return console;
|
||||||
});
|
});
|
||||||
@ -33,25 +33,9 @@ namespace Spectre.Console
|
|||||||
public static IAnsiConsoleCursor Cursor => _recorder?.Cursor ?? _console.Value.Cursor;
|
public static IAnsiConsoleCursor Cursor => _recorder?.Cursor ?? _console.Value.Cursor;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the console's capabilities.
|
/// Gets the console profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Capabilities Capabilities => Console.Capabilities;
|
public static Profile Profile => Console.Profile;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the buffer width of the console.
|
|
||||||
/// </summary>
|
|
||||||
public static int Width
|
|
||||||
{
|
|
||||||
get => Console.Width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the buffer height of the console.
|
|
||||||
/// </summary>
|
|
||||||
public static int Height
|
|
||||||
{
|
|
||||||
get => Console.Height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="IAnsiConsole"/> instance
|
/// Creates a new <see cref="IAnsiConsole"/> instance
|
||||||
@ -61,7 +45,8 @@ namespace Spectre.Console
|
|||||||
/// <returns>An <see cref="IAnsiConsole"/> instance.</returns>
|
/// <returns>An <see cref="IAnsiConsole"/> instance.</returns>
|
||||||
public static IAnsiConsole Create(AnsiConsoleSettings settings)
|
public static IAnsiConsole Create(AnsiConsoleSettings settings)
|
||||||
{
|
{
|
||||||
return BackendBuilder.Build(settings);
|
var factory = new AnsiConsoleFactory();
|
||||||
|
return factory.Create(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
178
src/Spectre.Console/AnsiConsoleFactory.cs
Normal file
178
src/Spectre.Console/AnsiConsoleFactory.cs
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Spectre.Console
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Factory for creating an ANSI console.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class AnsiConsoleFactory
|
||||||
|
{
|
||||||
|
private readonly List<IProfileEnricher> _enrichers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AnsiConsoleFactory"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public AnsiConsoleFactory()
|
||||||
|
{
|
||||||
|
_enrichers = new List<IProfileEnricher>
|
||||||
|
{
|
||||||
|
new AppVeyorProfile(),
|
||||||
|
new BambooProfile(),
|
||||||
|
new BitbucketProfile(),
|
||||||
|
new BitriseProfile(),
|
||||||
|
new ContinuaCIProfile(),
|
||||||
|
new GitHubProfile(),
|
||||||
|
new GitLabProfile(),
|
||||||
|
new GoCDProfile(),
|
||||||
|
new JenkinsProfile(),
|
||||||
|
new MyGetProfile(),
|
||||||
|
new TeamCityProfile(),
|
||||||
|
new TfsProfile(),
|
||||||
|
new TravisProfile(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AnsiConsoleFactory"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="enrichers">The profile enrichers to use.</param>
|
||||||
|
public AnsiConsoleFactory(IEnumerable<IProfileEnricher> enrichers)
|
||||||
|
{
|
||||||
|
_enrichers = new List<IProfileEnricher>(enrichers ?? Enumerable.Empty<IProfileEnricher>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="AnsiConsoleFactory"/> without default profile enrichers.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A new <see cref="AnsiConsoleFactory"/> without default profile enrichers.</returns>
|
||||||
|
public static AnsiConsoleFactory NoEnrichers()
|
||||||
|
{
|
||||||
|
return new AnsiConsoleFactory(Enumerable.Empty<IProfileEnricher>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an ANSI console.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="settings">The settings.</param>
|
||||||
|
/// <returns>An implementation of <see cref="IAnsiConsole"/>.</returns>
|
||||||
|
public IAnsiConsole Create(AnsiConsoleSettings settings)
|
||||||
|
{
|
||||||
|
if (settings is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
var buffer = settings.Out ?? System.Console.Out;
|
||||||
|
|
||||||
|
// Detect if the terminal support ANSI or not
|
||||||
|
var (supportsAnsi, legacyConsole) = DetectAnsi(settings, buffer);
|
||||||
|
|
||||||
|
// Use the provided encoding or fall back to UTF-8
|
||||||
|
var encoding = buffer.IsStandardOut() ? System.Console.OutputEncoding : Encoding.UTF8;
|
||||||
|
|
||||||
|
// Get the color system
|
||||||
|
var colorSystem = settings.ColorSystem == ColorSystemSupport.Detect
|
||||||
|
? ColorSystemDetector.Detect(supportsAnsi)
|
||||||
|
: (ColorSystem)settings.ColorSystem;
|
||||||
|
|
||||||
|
// Get whether or not we consider the terminal interactive
|
||||||
|
var interactive = settings.Interactive == InteractionSupport.Yes;
|
||||||
|
if (settings.Interactive == InteractionSupport.Detect)
|
||||||
|
{
|
||||||
|
interactive = Environment.UserInteractive;
|
||||||
|
}
|
||||||
|
|
||||||
|
var profile = new Profile("Default", buffer, encoding)
|
||||||
|
{
|
||||||
|
ColorSystem = colorSystem,
|
||||||
|
};
|
||||||
|
|
||||||
|
profile.Capabilities.Ansi = supportsAnsi;
|
||||||
|
profile.Capabilities.Links = supportsAnsi && !legacyConsole;
|
||||||
|
profile.Capabilities.Legacy = legacyConsole;
|
||||||
|
profile.Capabilities.Interactive = interactive;
|
||||||
|
|
||||||
|
// Enrich the profile
|
||||||
|
var variables = GetEnvironmentVariables(settings);
|
||||||
|
var customEnrichers = settings.Enrichers ?? Enumerable.Empty<IProfileEnricher>();
|
||||||
|
foreach (var enricher in _enrichers.Concat(customEnrichers))
|
||||||
|
{
|
||||||
|
if (enricher.Enabled(variables))
|
||||||
|
{
|
||||||
|
enricher.Enrich(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AnsiConsoleFacade(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IDictionary<string, string> GetEnvironmentVariables(AnsiConsoleSettings settings)
|
||||||
|
{
|
||||||
|
if (settings.EnvironmentVariables != null)
|
||||||
|
{
|
||||||
|
return new Dictionary<string, string>(settings.EnvironmentVariables, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Environment.GetEnvironmentVariables()
|
||||||
|
.Cast<System.Collections.DictionaryEntry>()
|
||||||
|
.Aggregate(
|
||||||
|
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase),
|
||||||
|
(dictionary, entry) =>
|
||||||
|
{
|
||||||
|
var key = (string)entry.Key;
|
||||||
|
if (!dictionary.TryGetValue(key, out _))
|
||||||
|
{
|
||||||
|
dictionary.Add(key, entry.Value as string ?? string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dictionary;
|
||||||
|
},
|
||||||
|
dictionary => dictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static (bool Ansi, bool Legacy) DetectAnsi(AnsiConsoleSettings settings, System.IO.TextWriter buffer)
|
||||||
|
{
|
||||||
|
var supportsAnsi = settings.Ansi == AnsiSupport.Yes;
|
||||||
|
var legacyConsole = false;
|
||||||
|
|
||||||
|
if (settings.Ansi == AnsiSupport.Detect)
|
||||||
|
{
|
||||||
|
(supportsAnsi, legacyConsole) = AnsiDetector.Detect(true);
|
||||||
|
|
||||||
|
// Check whether or not this is a legacy console from the existing instance (if any).
|
||||||
|
// We need to do this because once we upgrade the console to support ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||||
|
// on Windows, there is no way of detecting whether or not we're running on a legacy console or not.
|
||||||
|
if (AnsiConsole.Created && !legacyConsole && buffer.IsStandardOut() && AnsiConsole.Profile.Capabilities.Legacy)
|
||||||
|
{
|
||||||
|
legacyConsole = AnsiConsole.Profile.Capabilities.Legacy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (buffer.IsStandardOut())
|
||||||
|
{
|
||||||
|
// Are we running on Windows?
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
// Not the first console we're creating?
|
||||||
|
if (AnsiConsole.Created)
|
||||||
|
{
|
||||||
|
legacyConsole = AnsiConsole.Profile.Capabilities.Legacy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Try detecting whether or not this
|
||||||
|
(_, legacyConsole) = AnsiDetector.Detect(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (supportsAnsi, legacyConsole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console
|
||||||
@ -19,19 +20,25 @@ namespace Spectre.Console
|
|||||||
public ColorSystemSupport ColorSystem { get; set; }
|
public ColorSystemSupport ColorSystem { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether or
|
/// Gets or sets the out buffer.
|
||||||
/// not the console is interactive.
|
/// </summary>
|
||||||
|
public TextWriter? Out { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether or not the
|
||||||
|
/// terminal is interactive or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InteractionSupport Interactive { get; set; }
|
public InteractionSupport Interactive { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the link identity generator.
|
/// Gets or sets the environment variables.
|
||||||
|
/// If not value is provided the default environment variables will be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ILinkIdentityGenerator? LinkIdentityGenerator { get; set; }
|
public Dictionary<string, string>? EnvironmentVariables { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the out buffer.
|
/// Gets or sets the profile enrichers to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TextWriter? Out { get; set; }
|
public List<IProfileEnricher>? Enrichers { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -5,14 +7,16 @@ namespace Spectre.Console
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class Capabilities
|
public sealed class Capabilities
|
||||||
{
|
{
|
||||||
/// <summary>
|
private readonly Profile _profile;
|
||||||
/// Gets a value indicating whether or not
|
|
||||||
/// the console supports Ansi.
|
|
||||||
/// </summary>
|
|
||||||
public bool SupportsAnsi { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether or not
|
/// Gets or sets a value indicating whether or not
|
||||||
|
/// the console supports Ansi.
|
||||||
|
/// </summary>
|
||||||
|
public bool Ansi { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether or not
|
||||||
/// the console support links.
|
/// the console support links.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
@ -20,69 +24,48 @@ namespace Spectre.Console
|
|||||||
/// once we have more information about the terminal
|
/// once we have more information about the terminal
|
||||||
/// we're running inside.
|
/// we're running inside.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public bool SupportLinks => SupportsAnsi && !LegacyConsole;
|
public bool Links { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the color system.
|
/// Gets or sets a value indicating whether or not
|
||||||
/// </summary>
|
/// this is a legacy console (cmd.exe) on an OS
|
||||||
public ColorSystem ColorSystem { get; }
|
/// prior to Windows 10.
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a value indicating whether or not
|
|
||||||
/// this is a legacy console (cmd.exe).
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Only relevant when running on Microsoft Windows.
|
/// Only relevant when running on Microsoft Windows.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public bool LegacyConsole { get; }
|
public bool Legacy { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether or not the console supports interaction.
|
/// Gets a value indicating whether console output
|
||||||
|
/// has been redirected.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SupportsInteraction { get; set; }
|
public bool Tty
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_profile.Out.IsStandardOut())
|
||||||
|
{
|
||||||
|
return System.Console.IsOutputRedirected;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not stdout, so must be a TTY.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether
|
||||||
|
/// or not the console supports interaction.
|
||||||
|
/// </summary>
|
||||||
|
public bool Interactive { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Capabilities"/> class.
|
/// Initializes a new instance of the <see cref="Capabilities"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="supportsAnsi">Whether or not ANSI escape sequences are supported.</param>
|
internal Capabilities(Profile profile)
|
||||||
/// <param name="colorSystem">The color system that is supported.</param>
|
|
||||||
/// <param name="legacyConsole">Whether or not this is a legacy console.</param>
|
|
||||||
/// <param name="supportsInteraction">Whether or not the console supports interaction.</param>
|
|
||||||
public Capabilities(bool supportsAnsi, ColorSystem colorSystem, bool legacyConsole, bool supportsInteraction)
|
|
||||||
{
|
{
|
||||||
SupportsAnsi = supportsAnsi;
|
_profile = profile ?? throw new ArgumentNullException(nameof(profile));
|
||||||
ColorSystem = colorSystem;
|
|
||||||
LegacyConsole = legacyConsole;
|
|
||||||
SupportsInteraction = supportsInteraction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks whether the current capabilities supports
|
|
||||||
/// the specified color system.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="colorSystem">The color system to check.</param>
|
|
||||||
/// <returns><c>true</c> if the color system is supported, otherwise <c>false</c>.</returns>
|
|
||||||
public bool Supports(ColorSystem colorSystem)
|
|
||||||
{
|
|
||||||
return (int)colorSystem <= (int)ColorSystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
var supportsAnsi = SupportsAnsi ? "Yes" : "No";
|
|
||||||
var legacyConsole = LegacyConsole ? "Legacy" : "Modern";
|
|
||||||
var bits = ColorSystem switch
|
|
||||||
{
|
|
||||||
ColorSystem.NoColors => "1 bit",
|
|
||||||
ColorSystem.Legacy => "3 bits",
|
|
||||||
ColorSystem.Standard => "4 bits",
|
|
||||||
ColorSystem.EightBit => "8 bits",
|
|
||||||
ColorSystem.TrueColor => "24 bits",
|
|
||||||
_ => "?",
|
|
||||||
};
|
|
||||||
|
|
||||||
return $"ANSI={supportsAnsi}, Colors={ColorSystem}, Kind={legacyConsole} ({bits})";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli.Internal;
|
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Spectre.Console.Cli.Internal;
|
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
@ -7,7 +6,6 @@ namespace Spectre.Console.Cli
|
|||||||
/// Represents case sensitivity.
|
/// Represents case sensitivity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Flags]
|
[Flags]
|
||||||
[SuppressMessage("Naming", "CA1714:Flags enums should have plural names")]
|
|
||||||
public enum CaseSensitivity
|
public enum CaseSensitivity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2,7 +2,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Spectre.Console.Cli.Internal;
|
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
@ -74,11 +73,11 @@ namespace Spectre.Console.Cli
|
|||||||
if (!_executed)
|
if (!_executed)
|
||||||
{
|
{
|
||||||
// Add built-in (hidden) commands.
|
// Add built-in (hidden) commands.
|
||||||
_configurator.AddBranch(Constants.Commands.Branch, cli =>
|
_configurator.AddBranch(CliConstants.Commands.Branch, cli =>
|
||||||
{
|
{
|
||||||
cli.HideBranch();
|
cli.HideBranch();
|
||||||
cli.AddCommand<VersionCommand>(Constants.Commands.Version);
|
cli.AddCommand<VersionCommand>(CliConstants.Commands.Version);
|
||||||
cli.AddCommand<XmlDocCommand>(Constants.Commands.XmlDoc);
|
cli.AddCommand<XmlDocCommand>(CliConstants.Commands.XmlDoc);
|
||||||
});
|
});
|
||||||
|
|
||||||
_executed = true;
|
_executed = true;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Spectre.Console.Cli.Internal;
|
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Spectre.Console.Cli.Internal;
|
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli.Internal;
|
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
@ -33,7 +32,7 @@ namespace Spectre.Console.Cli
|
|||||||
|
|
||||||
internal static CommandRuntimeException MissingRequiredArgument(CommandTree node, CommandArgument argument)
|
internal static CommandRuntimeException MissingRequiredArgument(CommandTree node, CommandArgument argument)
|
||||||
{
|
{
|
||||||
if (node.Command.Name == Constants.DefaultCommandName)
|
if (node.Command.Name == CliConstants.DefaultCommandName)
|
||||||
{
|
{
|
||||||
return new CommandRuntimeException($"Missing required argument '{argument.Value}'.");
|
return new CommandRuntimeException($"Missing required argument '{argument.Value}'.");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Spectre.Console.Cli.Internal;
|
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandConstructorBinder
|
internal static class CommandConstructorBinder
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandPropertyBinder
|
internal static class CommandPropertyBinder
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandValueBinder
|
internal sealed class CommandValueBinder
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandValueLookup : IEnumerable<(CommandParameter Parameter, object? Value)>
|
internal sealed class CommandValueLookup : IEnumerable<(CommandParameter Parameter, object? Value)>
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandValueResolver
|
internal static class CommandValueResolver
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Representation of a multi map.
|
/// Representation of a multi map.
|
||||||
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
|
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
|
||||||
internal sealed class MultiMap<TKey, TValue> : IMultiMap, ILookup<TKey, TValue>, IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>
|
internal sealed class MultiMap<TKey, TValue> : IMultiMap, ILookup<TKey, TValue>, IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandBinder
|
internal static class CommandBinder
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandExecutor
|
internal sealed class CommandExecutor
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal enum CommandPart
|
internal enum CommandPart
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandSuggestor
|
internal static class CommandSuggestor
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandValidator
|
internal static class CommandValidator
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
[Description("Displays the CLI library version")]
|
[Description("Displays the CLI library version")]
|
||||||
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
|
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
|
||||||
|
@ -7,7 +7,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
[Description("Generates an XML representation of the CLI configuration.")]
|
[Description("Generates an XML representation of the CLI configuration.")]
|
||||||
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
|
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class Composer : IRenderable
|
internal sealed class Composer : IRenderable
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal abstract class ComponentActivator
|
internal abstract class ComponentActivator
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class ComponentRegistration
|
internal sealed class ComponentRegistration
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class ComponentRegistry : IDisposable
|
internal sealed class ComponentRegistry : IDisposable
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class DefaultTypeRegistrar : ITypeRegistrar
|
internal sealed class DefaultTypeRegistrar : ITypeRegistrar
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class DefaultTypeResolver : IDisposable, ITypeResolver
|
internal sealed class DefaultTypeResolver : IDisposable, ITypeResolver
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandAppSettings : ICommandAppSettings
|
internal sealed class CommandAppSettings : ICommandAppSettings
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandConfigurator : ICommandConfigurator
|
internal sealed class CommandConfigurator : ICommandConfigurator
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class ConfigurationHelper
|
internal static class ConfigurationHelper
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Spectre.Console.Cli.Unsafe;
|
using Spectre.Console.Cli.Unsafe;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class Configurator : IUnsafeConfigurator, IConfigurator, IConfiguration
|
internal sealed class Configurator : IUnsafeConfigurator, IConfigurator, IConfiguration
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ namespace Spectre.Console.Cli.Internal
|
|||||||
where TDefaultCommand : class, ICommand
|
where TDefaultCommand : class, ICommand
|
||||||
{
|
{
|
||||||
DefaultCommand = ConfiguredCommand.FromType<TDefaultCommand>(
|
DefaultCommand = ConfiguredCommand.FromType<TDefaultCommand>(
|
||||||
Constants.DefaultCommandName, isDefaultCommand: true);
|
CliConstants.DefaultCommandName, isDefaultCommand: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommandConfigurator AddCommand<TCommand>(string name)
|
public ICommandConfigurator AddCommand<TCommand>(string name)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli.Unsafe;
|
using Spectre.Console.Cli.Unsafe;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class Configurator<TSettings> : IUnsafeBranchConfigurator, IConfigurator<TSettings>
|
internal sealed class Configurator<TSettings> : IUnsafeBranchConfigurator, IConfigurator<TSettings>
|
||||||
where TSettings : CommandSettings
|
where TSettings : CommandSettings
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class ConfiguredCommand
|
internal sealed class ConfiguredCommand
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a configuration.
|
/// Represents a configuration.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class TemplateParser
|
internal static class TemplateParser
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class TemplateToken
|
internal sealed class TemplateToken
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class TemplateTokenizer
|
internal static class TemplateTokenizer
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class Constants
|
internal static class CliConstants
|
||||||
{
|
{
|
||||||
public const string DefaultCommandName = "__default_command";
|
public const string DefaultCommandName = "__default_command";
|
||||||
public const string True = "true";
|
public const string True = "true";
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
|
[SuppressMessage("Performance", "CA1812: Avoid uninstantiated internal classes")]
|
||||||
internal sealed class DefaultPairDeconstructor : IPairDeconstructor
|
internal sealed class DefaultPairDeconstructor : IPairDeconstructor
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class DelegateCommand : ICommand
|
internal sealed class DelegateCommand : ICommand
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandLineParseExceptionFactory
|
internal static class CommandLineParseExceptionFactory
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandLineTemplateExceptionFactory
|
internal static class CommandLineTemplateExceptionFactory
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class AnsiConsoleExtensions
|
internal static class AnsiConsoleExtensions
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CaseSensitivityExtensions
|
internal static class CaseSensitivityExtensions
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class ListExtensions
|
internal static class ListExtensions
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class TypeExtensions
|
internal static class TypeExtensions
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class TypeRegistrarExtensions
|
internal static class TypeRegistrarExtensions
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class XmlElementExtensions
|
internal static class XmlElementExtensions
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class HelpWriter
|
internal static class HelpWriter
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a pair deconstructor.
|
/// Represents a pair deconstructor.
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandArgument : CommandParameter
|
internal sealed class CommandArgument : CommandParameter
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandContainerExtensions
|
internal static class CommandContainerExtensions
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandInfo : ICommandContainer
|
internal sealed class CommandInfo : ICommandContainer
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandInfoExtensions
|
internal static class CommandInfoExtensions
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandModel : ICommandContainer
|
internal sealed class CommandModel : ICommandContainer
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandModelBuilder
|
internal static class CommandModelBuilder
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandModelValidator
|
internal static class CommandModelValidator
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandOption : CommandParameter
|
internal sealed class CommandOption : CommandParameter
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal abstract class CommandParameter : ICommandParameterInfo
|
internal abstract class CommandParameter : ICommandParameterInfo
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandParameterComparer
|
internal static class CommandParameterComparer
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a command container.
|
/// Represents a command container.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal enum ParameterKind
|
internal enum ParameterKind
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandTree
|
internal sealed class CommandTree
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandTreeExtensions
|
internal static class CommandTreeExtensions
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal class CommandTreeParser
|
internal class CommandTreeParser
|
||||||
{
|
{
|
||||||
@ -317,7 +317,7 @@ namespace Spectre.Console.Cli.Internal
|
|||||||
{
|
{
|
||||||
if (parameter.ParameterKind == ParameterKind.Flag)
|
if (parameter.ParameterKind == ParameterKind.Flag)
|
||||||
{
|
{
|
||||||
if (!Constants.AcceptedBooleanValues.Contains(valueToken.Value, StringComparer.OrdinalIgnoreCase))
|
if (!CliConstants.AcceptedBooleanValues.Contains(valueToken.Value, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// Flags cannot be assigned a value.
|
// Flags cannot be assigned a value.
|
||||||
throw CommandParseException.CannotAssignValueToFlag(context.Arguments, token);
|
throw CommandParseException.CannotAssignValueToFlag(context.Arguments, token);
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal class CommandTreeParserContext
|
internal class CommandTreeParserContext
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
// Consider removing this in favor for value tuples at some point.
|
// Consider removing this in favor for value tuples at some point.
|
||||||
internal sealed class CommandTreeParserResult
|
internal sealed class CommandTreeParserResult
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandTreeToken
|
internal sealed class CommandTreeToken
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandTreeTokenStream : IReadOnlyList<CommandTreeToken>
|
internal sealed class CommandTreeTokenStream : IReadOnlyList<CommandTreeToken>
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ using System.Globalization;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class CommandTreeTokenizer
|
internal static class CommandTreeTokenizer
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class CommandTreeTokenizerContext
|
internal sealed class CommandTreeTokenizerContext
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
// Consider removing this in favor for value tuples at some point.
|
// Consider removing this in favor for value tuples at some point.
|
||||||
internal sealed class MappedCommandParameter
|
internal sealed class MappedCommandParameter
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal enum ParsingMode
|
internal enum ParsingMode
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class RemainingArguments : IRemainingArguments
|
internal sealed class RemainingArguments : IRemainingArguments
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class StringWriterWithEncoding : StringWriter
|
internal sealed class StringWriterWithEncoding : StringWriter
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class TextBuffer : IDisposable
|
internal sealed class TextBuffer : IDisposable
|
||||||
{
|
{
|
||||||
// There is some kind of bug
|
// There is some kind of bug
|
||||||
[SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "VS bug")]
|
|
||||||
private readonly StringReader _reader;
|
private readonly StringReader _reader;
|
||||||
|
|
||||||
public bool ReachedEnd => _reader.Peek() == -1;
|
public bool ReachedEnd => _reader.Peek() == -1;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class TypeRegistrar : ITypeRegistrarFrontend
|
internal sealed class TypeRegistrar : ITypeRegistrarFrontend
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal sealed class TypeResolverAdapter : ITypeResolver
|
internal sealed class TypeResolverAdapter : ITypeResolver
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Spectre.Console.Cli.Internal
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
internal static class VersionHelper
|
internal static class VersionHelper
|
||||||
{
|
{
|
||||||
[SuppressMessage("Design", "CA1031:Do not catch general exception types")]
|
|
||||||
public static string GetVersion(Assembly? assembly)
|
public static string GetVersion(Assembly? assembly)
|
||||||
{
|
{
|
||||||
if (assembly == null)
|
if (assembly == null)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Spectre.Console.Cli.Internal;
|
|
||||||
|
|
||||||
namespace Spectre.Console.Cli
|
namespace Spectre.Console.Cli
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user