mirror of
https://github.com/nsnail/dot.git
synced 2025-06-19 22:08:16 +08:00
<refactor> 移除 https://github.com/commandlineparser/commandline.git
This commit is contained in:
@ -5,19 +5,13 @@ using NSExt.Extensions;
|
||||
|
||||
namespace Dot.Git;
|
||||
|
||||
[Description(nameof(Str.GitTool))]
|
||||
[Localization(typeof(Str))]
|
||||
public class Main : ToolBase<Option>
|
||||
{
|
||||
private readonly Encoding _gitOutputEnc; //git command rsp 编码
|
||||
private ConcurrentDictionary<string, StringBuilder> _repoRsp; //仓库信息容器
|
||||
private ConcurrentDictionary<string, TaskStatusColumn.Statues> _repoStatus;
|
||||
|
||||
public Main(Option opt) : base(opt)
|
||||
{
|
||||
_gitOutputEnc = Encoding.GetEncoding(Opt.GitOutputEncoding);
|
||||
if (!Directory.Exists(Opt.Path))
|
||||
throw new ArgumentException(nameof(Opt.Path) //
|
||||
, string.Format(Str.PathNotFound, Opt.Path));
|
||||
}
|
||||
private Encoding _gitOutputEnc; //git command rsp 编码
|
||||
private ConcurrentDictionary<string, StringBuilder> _repoRsp; //仓库信息容器
|
||||
private ConcurrentDictionary<string, TaskStatusColumn.Statues> _repoStatus;
|
||||
|
||||
|
||||
private async ValueTask DirHandle(KeyValuePair<string, ProgressTask> payload, CancellationToken _)
|
||||
@ -67,9 +61,14 @@ public class Main : ToolBase<Option>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override async Task Core()
|
||||
{
|
||||
_gitOutputEnc = Encoding.GetEncoding(Opt.GitOutputEncoding);
|
||||
if (!Directory.Exists(Opt.Path))
|
||||
throw new ArgumentException(nameof(Opt.Path) //
|
||||
, string.Format(Str.PathNotFound, Opt.Path));
|
||||
|
||||
|
||||
var progressBar = new ProgressBarColumn { Width = 10 };
|
||||
await AnsiConsole.Progress()
|
||||
.Columns(progressBar //
|
||||
|
@ -1,19 +1,29 @@
|
||||
namespace Dot.Git;
|
||||
|
||||
[Verb("git", HelpText = nameof(Str.GitTool), ResourceType = typeof(Str))]
|
||||
public class Option : OptionBase
|
||||
{
|
||||
[Option('a', "args", HelpText = nameof(Str.GitArgs), Default = "status", ResourceType = typeof(Str))]
|
||||
[CommandOption("-a|--args")]
|
||||
[Description(nameof(Str.GitArgs))]
|
||||
[Localization(typeof(Str))]
|
||||
[DefaultValue("status")]
|
||||
public string Args { get; set; }
|
||||
|
||||
[Option('e', "git-output-encoding", HelpText = nameof(Str.GitOutputEncoding), Default = "utf-8"
|
||||
, ResourceType = typeof(Str))]
|
||||
[CommandOption("-e|--git-output-encoding")]
|
||||
[Description(nameof(Str.GitOutputEncoding))]
|
||||
[Localization(typeof(Str))]
|
||||
[DefaultValue("utf-8")]
|
||||
public string GitOutputEncoding { get; set; }
|
||||
|
||||
[Option('d', "max-recursion-depth", HelpText = nameof(Str.MaxRecursionDepth), Default = int.MaxValue
|
||||
, ResourceType = typeof(Str))]
|
||||
[CommandOption("-d|--max-recursion-depth")]
|
||||
[Description(nameof(Str.MaxRecursionDepth))]
|
||||
[Localization(typeof(Str))]
|
||||
[DefaultValue(int.MaxValue)]
|
||||
public int MaxRecursionDepth { get; set; }
|
||||
|
||||
[Value(0, HelpText = nameof(Str.FolderPath), Default = ".", ResourceType = typeof(Str))]
|
||||
|
||||
[CommandArgument(0, "[path]")]
|
||||
[Description(nameof(Str.FolderPath))]
|
||||
[Localization(typeof(Str))]
|
||||
[DefaultValue(".")]
|
||||
public string Path { get; set; }
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
using System.ComponentModel;
|
||||
using NSExt.Extensions;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
|
Reference in New Issue
Block a user