<refactor>

This commit is contained in:
nsnail 2022-12-12 19:51:19 +08:00
parent 1c66b36e34
commit a35ebfcb23
9 changed files with 30 additions and 23 deletions

View File

@ -7,6 +7,12 @@
"commands": [ "commands": [
"t4" "t4"
] ]
},
"dotnet-consolidate": {
"version": "2.0.0",
"commands": [
"dotnet-consolidate"
]
} }
} }
} }

View File

@ -8,19 +8,19 @@ app.Configure(config => {
config.SetApplicationName(AssemblyInfo.ASSEMBLY_PRODUCT); config.SetApplicationName(AssemblyInfo.ASSEMBLY_PRODUCT);
config.SetApplicationVersion(AssemblyInfo.ASSEMBLY_VERSION); config.SetApplicationVersion(AssemblyInfo.ASSEMBLY_VERSION);
config.AddCommand<Main>("git"); config.AddCommand<Main>(nameof(Dot.Git).ToLower());
#if NET7_0_WINDOWS #if NET7_0_WINDOWS
config.AddCommand<Dot.Color.Main>("color"); config.AddCommand<Dot.Color.Main>(nameof(Dot.Color).ToLower());
#endif #endif
config.AddCommand<Dot.Guid.Main>("guid"); config.AddCommand<Dot.Guid.Main>(nameof(Dot.Guid).ToLower());
config.AddCommand<Dot.IP.Main>("ip"); config.AddCommand<Dot.IP.Main>(nameof(Dot.IP).ToLower());
config.AddCommand<Dot.Json.Main>("json"); config.AddCommand<Dot.Json.Main>(nameof(Dot.Json).ToLower());
config.AddCommand<Dot.Pwd.Main>("pwd"); config.AddCommand<Dot.Pwd.Main>(nameof(Dot.Pwd).ToLower());
config.AddCommand<Dot.RmBlank.Main>("rblank"); config.AddCommand<Dot.Rbom.Main>(nameof(Dot.Rbom).ToLower());
config.AddCommand<Dot.RmBom.Main>("rbom"); config.AddCommand<Dot.Trim.Main>(nameof(Dot.Trim).ToLower());
config.AddCommand<Dot.Text.Main>("text"); config.AddCommand<Dot.Text.Main>(nameof(Dot.Text).ToLower());
config.AddCommand<Dot.Time.Main>("time"); config.AddCommand<Dot.Time.Main>(nameof(Dot.Time).ToLower());
config.AddCommand<Dot.ToLf.Main>("tolf"); config.AddCommand<Dot.ToLf.Main>(nameof(Dot.ToLf).ToLower());
config.ValidateExamples(); config.ValidateExamples();

View File

@ -1,4 +1,4 @@
namespace Dot.RmBom; namespace Dot.Rbom;
[Description(nameof(Str.TrimUtf8Bom))] [Description(nameof(Str.TrimUtf8Bom))]
[Localization(typeof(Str))] [Localization(typeof(Str))]

3
src/Rbom/Option.cs Normal file
View File

@ -0,0 +1,3 @@
namespace Dot.Rbom;
public class Option : DirOption { }

View File

@ -1,3 +0,0 @@
namespace Dot.RmBom;
public class Option : DirOption { }

View File

@ -137,7 +137,7 @@ public sealed class Main : ToolBase<Option>
} }
} }
public override async Task Run() protected override async Task Run()
{ {
await Core(); await Core();
if (Opt.KeepSession) { if (Opt.KeepSession) {

View File

@ -2,7 +2,7 @@ namespace Dot;
public abstract class ToolBase<TOption> : Command<TOption> where TOption : OptionBase public abstract class ToolBase<TOption> : Command<TOption> where TOption : OptionBase
{ {
protected TOption Opt { get; set; } protected TOption Opt { get; private set; }
protected abstract Task Core(); protected abstract Task Core();
public override int Execute(CommandContext context, TOption option) public override int Execute(CommandContext context, TOption option)
@ -12,7 +12,7 @@ public abstract class ToolBase<TOption> : Command<TOption> where TOption : Optio
return 0; return 0;
} }
public virtual async Task Run() protected virtual async Task Run()
{ {
await Core(); await Core();
if (Opt.KeepSession) { if (Opt.KeepSession) {

View File

@ -1,6 +1,7 @@
using Dot.RmBlank;
using NSExt.Extensions; using NSExt.Extensions;
namespace Dot.RmBlank; namespace Dot.Trim;
[Description(nameof(Str.RemoveTrailingWhiteSpaces))] [Description(nameof(Str.RemoveTrailingWhiteSpaces))]
[Localization(typeof(Str))] [Localization(typeof(Str))]