This commit is contained in:
2022-12-09 16:39:04 +08:00
parent f4b7c5d0ad
commit 0594ec1836
37 changed files with 276 additions and 183 deletions

View File

@ -8,6 +8,8 @@ using System.Diagnostics;
namespace Dot.Text;
[Description(nameof(Str.TextTool))]
[Localization(typeof(Str))]
public sealed class Main : ToolBase<Option>
{
private ref struct Output
@ -28,7 +30,6 @@ public sealed class Main : ToolBase<Option>
public ReadOnlySpan<char> UrlEncode;
}
public Main(Option opt) : base(opt) { }
private static Output BuildOutput(string text, Encoding enc)
{
@ -107,7 +108,11 @@ html-decode: {o.HtmlDecode}
#endif
}
#if NET7_0_WINDOWS
protected override async Task Core()
#else
protected override Task Core()
#endif
{
#if NET7_0_WINDOWS
if (Opt.Text.NullOrEmpty()) Opt.Text = await ClipboardService.GetTextAsync();
@ -116,5 +121,8 @@ html-decode: {o.HtmlDecode}
ParseAndShow(Opt.Text);
#if !NET7_0_WINDOWS
return Task.CompletedTask;
#endif
}
}

View File

@ -1,8 +1,9 @@
namespace Dot.Text;
[Verb("text", HelpText = nameof(Str.TextTool), ResourceType = typeof(Str))]
public class Option : OptionBase
{
[Value(0, HelpText = nameof(Str.TextTobeProcessed), ResourceType = typeof(Str))]
[CommandArgument(0, "[input text]")]
[Description(nameof(Str.TextTobeProcessed))]
[Localization(typeof(Str))]
public string Text { get; set; }
}