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

@ -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 //

View File

@ -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; }
}

View File

@ -1,4 +1,3 @@
using System.ComponentModel;
using NSExt.Extensions;
using Spectre.Console.Rendering;