mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-02 02:48:17 +08:00
Move Spectre.Console.Cli to it's own package
This commit is contained in:

committed by
Patrik Svensson

parent
b600832e00
commit
36ca22ffac
@ -0,0 +1,44 @@
|
||||
namespace Spectre.Console.Cli;
|
||||
|
||||
internal sealed class CommandTreeTokenizerContext
|
||||
{
|
||||
private readonly StringBuilder _builder;
|
||||
private readonly List<string> _remaining;
|
||||
|
||||
public CommandTreeTokenizer.Mode Mode { get; set; }
|
||||
public IReadOnlyList<string> Remaining => _remaining;
|
||||
|
||||
public CommandTreeTokenizerContext()
|
||||
{
|
||||
_builder = new StringBuilder();
|
||||
_remaining = new List<string>();
|
||||
}
|
||||
|
||||
public void AddRemaining(char character)
|
||||
{
|
||||
if (Mode == CommandTreeTokenizer.Mode.Remaining)
|
||||
{
|
||||
_builder.Append(character);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRemaining(string text)
|
||||
{
|
||||
if (Mode == CommandTreeTokenizer.Mode.Remaining)
|
||||
{
|
||||
_builder.Append(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void FlushRemaining()
|
||||
{
|
||||
if (Mode == CommandTreeTokenizer.Mode.Remaining)
|
||||
{
|
||||
if (_builder.Length > 0)
|
||||
{
|
||||
_remaining.Add(_builder.ToString());
|
||||
_builder.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user