mirror of
https://github.com/nsnail/dot.git
synced 2025-06-17 21:13:21 +08:00
<clean>
This commit is contained in:
parent
6693a66b30
commit
750545c2d0
18
README.md
18
README.md
@ -6,7 +6,8 @@ Cross-platform, all-around utility set with a beautiful character interface-the
|
|||||||
|
|
||||||
### Brief introduction
|
### Brief introduction
|
||||||
|
|
||||||
The dot is the one based on the one. NET 7, a cross-platform command-line tool, integrates more than 10 utilities that program developers often use in their daily work, and is constantly increasing.
|
The dot is the one based on the one. NET 7, a cross-platform command-line tool, integrates more than 10 utilities that
|
||||||
|
program developers often use in their daily work, and is constantly increasing.
|
||||||
|
|
||||||
```
|
```
|
||||||
USAGE:
|
USAGE:
|
||||||
@ -33,8 +34,6 @@ COMMANDS:
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Some functional examples
|
### Some functional examples
|
||||||
|
|
||||||
- ##### Git batch management
|
- ##### Git batch management
|
||||||
@ -56,7 +55,10 @@ dot git -a "config --get http.proxy" d:\repos
|
|||||||

|

|
||||||
|
|
||||||
- ##### High-precision time-clock synchronization
|
- ##### High-precision time-clock synchronization
|
||||||
Supports parallel requests from multiple NTP clock servers, while removing the network communication duration to set the precise synchronization of the native clocks with the NTP standard time:
|
|
||||||
|
Supports parallel requests from multiple NTP clock servers, while removing the network communication duration to set the
|
||||||
|
precise synchronization of the native clocks with the NTP standard time:
|
||||||
|
|
||||||
```
|
```
|
||||||
dot time -k
|
dot time -k
|
||||||
```
|
```
|
||||||
@ -64,25 +66,29 @@ dot time -k
|
|||||||

|

|
||||||
|
|
||||||
- ##### Text codec
|
- ##### Text codec
|
||||||
|
|
||||||
Copy you need to view various codec text in the clipboard, and then enter the following command to view
|
Copy you need to view various codec text in the clipboard, and then enter the following command to view
|
||||||
|
|
||||||
```
|
```
|
||||||
dot text
|
dot text
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
- ##### Multi-threading download tool
|
- ##### Multi-threading download tool
|
||||||
|
|
||||||
Support setting the block size, number of threads to replace the single thread wget tool:
|
Support setting the block size, number of threads to replace the single thread wget tool:
|
||||||
|
|
||||||
```
|
```
|
||||||
dot get https://github.com/nsnail/dot/releases/download/v1.1.1/dot-v1.1.1-win-x64.7z
|
dot get https://github.com/nsnail/dot/releases/download/v1.1.1/dot-v1.1.1-win-x64.7z
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
- ##### Remove the blank at the end of the file
|
- ##### Remove the blank at the end of the file
|
||||||
|
|
||||||
Remove excess spaces and line breaks in the tail of all files in the specified directory:
|
Remove excess spaces and line breaks in the tail of all files in the specified directory:
|
||||||
|
|
||||||
```
|
```
|
||||||
dot trim d:\repos
|
dot trim d:\repos
|
||||||
```
|
```
|
||||||
|
@ -13,27 +13,25 @@ USAGE:
|
|||||||
dot [OPTIONS] <COMMAND>
|
dot [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
-v, --version Prints version information
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
git Git批量操作工具
|
git Git批量操作工具
|
||||||
color 屏幕坐标颜色选取工具
|
color 屏幕坐标颜色选取工具
|
||||||
guid GUID工具
|
guid GUID工具
|
||||||
ip IP工具
|
ip IP工具
|
||||||
json Json工具
|
json Json工具
|
||||||
pwd <password length> <generate type> 随机密码生成器
|
pwd <password length> <generate type> 随机密码生成器
|
||||||
rbom 移除文件的uf8 bom
|
rbom 移除文件的uf8 bom
|
||||||
trim 移除文件尾部换行和空格
|
trim 移除文件尾部换行和空格
|
||||||
text 文本编码工具
|
text 文本编码工具
|
||||||
time 时间同步工具
|
time 时间同步工具
|
||||||
tolf 转换换行符为LF
|
tolf 转换换行符为LF
|
||||||
get <url> 多线程下载工具
|
get <url> 多线程下载工具
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 部分功能示例
|
### 部分功能示例
|
||||||
|
|
||||||
- ##### Git批量管理
|
- ##### Git批量管理
|
||||||
@ -55,7 +53,9 @@ dot git -a "config --get http.proxy" d:\repos
|
|||||||

|

|
||||||
|
|
||||||
- ##### 高精度时钟同步
|
- ##### 高精度时钟同步
|
||||||
|
|
||||||
支持多个NTP时钟服务器并行请求,同时除去网络通信时长以设置本机时钟与NTP标准时间精确同步:
|
支持多个NTP时钟服务器并行请求,同时除去网络通信时长以设置本机时钟与NTP标准时间精确同步:
|
||||||
|
|
||||||
```
|
```
|
||||||
dot time -k
|
dot time -k
|
||||||
```
|
```
|
||||||
@ -63,25 +63,29 @@ dot time -k
|
|||||||

|

|
||||||
|
|
||||||
- ##### 文本编解码
|
- ##### 文本编解码
|
||||||
|
|
||||||
复制你需要查看各种编解码的文本在剪贴板中,然后输入如下命令,即可查看
|
复制你需要查看各种编解码的文本在剪贴板中,然后输入如下命令,即可查看
|
||||||
|
|
||||||
```
|
```
|
||||||
dot text
|
dot text
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
- ##### 多线程下载工具
|
- ##### 多线程下载工具
|
||||||
|
|
||||||
支持设置分块大小,线程数量,用以替代单线程的wget工具:
|
支持设置分块大小,线程数量,用以替代单线程的wget工具:
|
||||||
|
|
||||||
```
|
```
|
||||||
dot get https://github.com/nsnail/dot/releases/download/v1.1.1/dot-v1.1.1-win-x64.7z
|
dot get https://github.com/nsnail/dot/releases/download/v1.1.1/dot-v1.1.1-win-x64.7z
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
- ##### 移除文件末尾空白
|
- ##### 移除文件末尾空白
|
||||||
|
|
||||||
移除指定目录下所有文件尾部多余的空格和换行符:
|
移除指定目录下所有文件尾部多余的空格和换行符:
|
||||||
|
|
||||||
```
|
```
|
||||||
dot trim d:\repos
|
dot trim d:\repos
|
||||||
```
|
```
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
#if NET7_0_WINDOWS
|
#if NET7_0_WINDOWS
|
||||||
namespace Dot.Color;
|
namespace Dot.Color;
|
||||||
|
|
||||||
[Description(nameof(Str.ScreenPixelTool))]
|
[Description(nameof(Str.ScreenPixelTool))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : ToolBase<Option>
|
internal sealed class Main : ToolBase<Option>
|
||||||
|
|
||||||
{
|
{
|
||||||
protected override Task Core()
|
protected override Task Core()
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
#if NET7_0_WINDOWS
|
#if NET7_0_WINDOWS
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Dot.Color;
|
namespace Dot.Color;
|
||||||
|
|
||||||
public class MouseHook : IDisposable
|
internal class MouseHook : IDisposable
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
private struct Msllhookstruct
|
private struct Msllhookstruct
|
||||||
@ -18,6 +20,7 @@ public class MouseHook : IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ReSharper disable once EventNeverSubscribedTo.Global
|
||||||
public event MouseEventHandler MouseEvent = delegate { };
|
public event MouseEventHandler MouseEvent = delegate { };
|
||||||
private const int _WH_MOUSE_LL = 14;
|
private const int _WH_MOUSE_LL = 14;
|
||||||
private const int _WM_LBUTTONDOWN = 0x0201;
|
private const int _WM_LBUTTONDOWN = 0x0201;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
namespace Dot.Color;
|
namespace Dot.Color;
|
||||||
|
|
||||||
public class Option : OptionBase { }
|
internal class Option : OptionBase { }
|
@ -4,7 +4,7 @@ using Size = System.Drawing.Size;
|
|||||||
|
|
||||||
namespace Dot.Color;
|
namespace Dot.Color;
|
||||||
|
|
||||||
public class WinInfo : Form
|
internal class WinInfo : Form
|
||||||
{
|
{
|
||||||
private const int _WINDOW_SIZE = 480; //窗口大小
|
private const int _WINDOW_SIZE = 480; //窗口大小
|
||||||
private const int _ZOOM_RATE = 16; //缩放倍率
|
private const int _ZOOM_RATE = 16; //缩放倍率
|
||||||
|
@ -3,7 +3,7 @@ using TextCopy;
|
|||||||
|
|
||||||
namespace Dot.Color;
|
namespace Dot.Color;
|
||||||
|
|
||||||
public class WinMain : Form
|
internal class WinMain : Form
|
||||||
{
|
{
|
||||||
private readonly Bitmap _bmp;
|
private readonly Bitmap _bmp;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Dot;
|
namespace Dot;
|
||||||
|
|
||||||
// ReSharper disable once UnusedType.Global
|
// ReSharper disable once UnusedType.Global
|
||||||
public class CsxEditor
|
internal class CsxEditor
|
||||||
{
|
{
|
||||||
// ReSharper disable once UnusedMember.Local
|
// ReSharper disable once UnusedMember.Local
|
||||||
#pragma warning disable CA1822
|
#pragma warning disable CA1822
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
namespace Dot;
|
namespace Dot;
|
||||||
|
|
||||||
public class DirOption : OptionBase
|
internal class DirOption : OptionBase
|
||||||
{
|
{
|
||||||
[CommandOption("-e|--exclude")]
|
[CommandOption("-e|--exclude")]
|
||||||
[Description(nameof(Str.ExcludePathRegexes))]
|
[Description(nameof(Str.ExcludePathRegexes))]
|
||||||
|
@ -4,11 +4,13 @@ using Panel = Spectre.Console.Panel;
|
|||||||
|
|
||||||
namespace Dot;
|
namespace Dot;
|
||||||
|
|
||||||
public abstract class FilesTool<TOption> : ToolBase<TOption> where TOption : DirOption
|
internal abstract class FilesTool<TOption> : ToolBase<TOption> where TOption : DirOption
|
||||||
{
|
{
|
||||||
private int _breakCnt; //跳过文件数
|
private int _breakCnt; //跳过文件数
|
||||||
private ProgressTask _childTask; //子任务进度
|
private ProgressTask _childTask; //子任务进度
|
||||||
private int _excludeCnt; //排除文件数
|
private int _excludeCnt; //排除文件数
|
||||||
|
|
||||||
|
// ReSharper disable once StaticMemberInGenericType
|
||||||
private static readonly object _lock = new(); //线程锁
|
private static readonly object _lock = new(); //线程锁
|
||||||
private int _readCnt; //读取文件数
|
private int _readCnt; //读取文件数
|
||||||
private int _totalCnt; //总文件数
|
private int _totalCnt; //总文件数
|
||||||
@ -16,6 +18,7 @@ public abstract class FilesTool<TOption> : ToolBase<TOption> where TOption : Dir
|
|||||||
private readonly ConcurrentDictionary<string, int> _writeStats = new(); //写入统计:后缀,数量
|
private readonly ConcurrentDictionary<string, int> _writeStats = new(); //写入统计:后缀,数量
|
||||||
|
|
||||||
|
|
||||||
|
// ReSharper disable once ReturnTypeCanBeEnumerable.Local
|
||||||
private string[] EnumerateFiles(string path, string searchPattern, out int excludeCnt)
|
private string[] EnumerateFiles(string path, string searchPattern, out int excludeCnt)
|
||||||
{
|
{
|
||||||
var exCnt = 0;
|
var exCnt = 0;
|
||||||
@ -76,7 +79,7 @@ public abstract class FilesTool<TOption> : ToolBase<TOption> where TOption : Dir
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected FileStream CreateTempFile(out string file)
|
protected static FileStream CreateTempFile(out string file)
|
||||||
{
|
{
|
||||||
file = Path.Combine(Path.GetTempPath(), $"{System.Guid.NewGuid()}.tmp");
|
file = Path.Combine(Path.GetTempPath(), $"{System.Guid.NewGuid()}.tmp");
|
||||||
return OpenFileStream(file, FileMode.OpenOrCreate, FileAccess.Write);
|
return OpenFileStream(file, FileMode.OpenOrCreate, FileAccess.Write);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
@ -6,7 +8,7 @@ namespace Dot.Get;
|
|||||||
|
|
||||||
[Description(nameof(Str.DownloadTool))]
|
[Description(nameof(Str.DownloadTool))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public partial class Main : ToolBase<Option>
|
internal partial class Main : ToolBase<Option>
|
||||||
{
|
{
|
||||||
private const string _PART = "part";
|
private const string _PART = "part";
|
||||||
|
|
||||||
@ -84,8 +86,8 @@ public partial class Main : ToolBase<Option>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void WritePart(HttpResponseMessage rsp, string mainFilePath //
|
private void WritePart(HttpResponseMessage rsp, string mainFilePath //
|
||||||
, long startPos, long endPos //
|
, long startPos, long endPos //
|
||||||
, Action<int> rateHandle)
|
, Action<int> rateHandle)
|
||||||
{
|
{
|
||||||
Span<byte> buf = stackalloc byte[Opt.BufferSize];
|
Span<byte> buf = stackalloc byte[Opt.BufferSize];
|
||||||
using var stream = rsp.Content.ReadAsStream();
|
using var stream = rsp.Content.ReadAsStream();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
namespace Dot.Get;
|
namespace Dot.Get;
|
||||||
|
|
||||||
public class Option : OptionBase
|
internal class Option : OptionBase
|
||||||
{
|
{
|
||||||
[CommandOption("-b|--buffer-size")]
|
[CommandOption("-b|--buffer-size")]
|
||||||
[Description(nameof(Str.BufferSize))]
|
[Description(nameof(Str.BufferSize))]
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -7,7 +9,7 @@ namespace Dot.Git;
|
|||||||
|
|
||||||
[Description(nameof(Str.GitTool))]
|
[Description(nameof(Str.GitTool))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public class Main : ToolBase<Option>
|
internal class Main : ToolBase<Option>
|
||||||
{
|
{
|
||||||
private Encoding _gitOutputEnc; //git command rsp 编码
|
private Encoding _gitOutputEnc; //git command rsp 编码
|
||||||
private ConcurrentDictionary<string, StringBuilder> _repoRsp; //仓库信息容器
|
private ConcurrentDictionary<string, StringBuilder> _repoRsp; //仓库信息容器
|
||||||
@ -43,7 +45,7 @@ public class Main : ToolBase<Option>
|
|||||||
p.ErrorDataReceived += ExecRspReceived;
|
p.ErrorDataReceived += ExecRspReceived;
|
||||||
p.BeginOutputReadLine();
|
p.BeginOutputReadLine();
|
||||||
p.BeginErrorReadLine();
|
p.BeginErrorReadLine();
|
||||||
await p.WaitForExitAsync();
|
await p.WaitForExitAsync(CancellationToken.None);
|
||||||
|
|
||||||
if (p.ExitCode == 0) {
|
if (p.ExitCode == 0) {
|
||||||
payload.Value.State.Status(TaskStatusColumn.Statues.Succeed);
|
payload.Value.State.Status(TaskStatusColumn.Statues.Succeed);
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
namespace Dot.Git;
|
namespace Dot.Git;
|
||||||
|
|
||||||
public class Option : OptionBase
|
internal class Option : OptionBase
|
||||||
{
|
{
|
||||||
[CommandOption("-a|--args")]
|
[CommandOption("-a|--args")]
|
||||||
[Description(nameof(Str.GitArgs))]
|
[Description(nameof(Str.GitArgs))]
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
namespace Dot.Git;
|
namespace Dot.Git;
|
||||||
|
|
||||||
public static class ProgressTaskStateExtensions
|
internal static class ProgressTaskStateExtensions
|
||||||
{
|
{
|
||||||
public static TaskStatusColumn.Statues Status(this ProgressTaskState me)
|
|
||||||
{
|
|
||||||
return me.Get<TaskStatusColumn.Statues>(nameof(TaskStatusColumn));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Status(this ProgressTaskState me, TaskStatusColumn.Statues value)
|
public static void Status(this ProgressTaskState me, TaskStatusColumn.Statues value)
|
||||||
{
|
{
|
||||||
me.Update<TaskStatusColumn.Statues>(nameof(TaskStatusColumn), _ => value);
|
me.Update<TaskStatusColumn.Statues>(nameof(TaskStatusColumn), _ => value);
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||||
|
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Dot.Git;
|
namespace Dot.Git;
|
||||||
|
|
||||||
public class TaskStatusColumn : ProgressColumn
|
internal class TaskStatusColumn : ProgressColumn
|
||||||
{
|
{
|
||||||
public enum Statues : byte
|
public enum Statues : byte
|
||||||
{
|
{
|
||||||
[Description($"[gray]{nameof(Ready)}[/]")]
|
[Description($"[gray]{nameof(Ready)}[/]")]
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
Ready
|
Ready
|
||||||
|
|
||||||
, [Description($"[yellow]{nameof(Executing)}[/]")]
|
, [Description($"[yellow]{nameof(Executing)}[/]")]
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
#if NET7_0_WINDOWS
|
#if NET7_0_WINDOWS
|
||||||
using TextCopy;
|
using TextCopy;
|
||||||
#endif
|
#endif
|
||||||
@ -6,7 +9,7 @@ namespace Dot.Guid;
|
|||||||
|
|
||||||
[Description(nameof(Str.GuidTool))]
|
[Description(nameof(Str.GuidTool))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : ToolBase<Option>
|
internal sealed class Main : ToolBase<Option>
|
||||||
{
|
{
|
||||||
protected override Task Core()
|
protected override Task Core()
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
namespace Dot.Guid;
|
namespace Dot.Guid;
|
||||||
|
|
||||||
public class Option : OptionBase
|
internal class Option : OptionBase
|
||||||
{
|
{
|
||||||
[CommandOption("-u|--upper")]
|
[CommandOption("-u|--upper")]
|
||||||
[Description(nameof(Str.UseUppercase))]
|
[Description(nameof(Str.UseUppercase))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
public bool Upper { get; set; } //normal options here
|
public bool Upper { get; set; }
|
||||||
}
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
||||||
@ -5,7 +7,7 @@ namespace Dot.IP;
|
|||||||
|
|
||||||
[Description(nameof(Str.Ip))]
|
[Description(nameof(Str.Ip))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : ToolBase<Option>
|
internal sealed class Main : ToolBase<Option>
|
||||||
|
|
||||||
{
|
{
|
||||||
protected override async Task Core()
|
protected override async Task Core()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
namespace Dot.IP;
|
namespace Dot.IP;
|
||||||
|
|
||||||
public class Option : OptionBase { }
|
internal class Option : OptionBase { }
|
@ -1,3 +1,5 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
#if NET7_0_WINDOWS
|
#if NET7_0_WINDOWS
|
||||||
@ -9,7 +11,7 @@ namespace Dot.Json;
|
|||||||
|
|
||||||
[Description(nameof(Str.Json))]
|
[Description(nameof(Str.Json))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public class Main : ToolBase<Option>
|
internal class Main : ToolBase<Option>
|
||||||
{
|
{
|
||||||
private object _inputObj;
|
private object _inputObj;
|
||||||
|
|
||||||
@ -43,7 +45,7 @@ public class Main : ToolBase<Option>
|
|||||||
var inputText = Opt.InputText;
|
var inputText = Opt.InputText;
|
||||||
|
|
||||||
#if NET7_0_WINDOWS
|
#if NET7_0_WINDOWS
|
||||||
if (inputText.NullOrWhiteSpace()) inputText = ClipboardService.GetText();
|
if (inputText.NullOrWhiteSpace()) inputText = await ClipboardService.GetTextAsync();
|
||||||
#endif
|
#endif
|
||||||
if (inputText.NullOrWhiteSpace()) throw new ArgumentException(Str.InputTextIsEmpty);
|
if (inputText.NullOrWhiteSpace()) throw new ArgumentException(Str.InputTextIsEmpty);
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
namespace Dot.Json;
|
namespace Dot.Json;
|
||||||
|
|
||||||
public class Option : OptionBase
|
internal class Option : OptionBase
|
||||||
{
|
{
|
||||||
[CommandOption("-c|--compress")]
|
[CommandOption("-c|--compress")]
|
||||||
[Description(nameof(Str.CompressJson))]
|
[Description(nameof(Str.CompressJson))]
|
||||||
|
@ -27,7 +27,7 @@ namespace Dot.Lang {
|
|||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
public class Str {
|
internal class Str {
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
@ -68,14 +68,14 @@ namespace Dot.Lang {
|
|||||||
<#
|
<#
|
||||||
var xml = new XmlDocument();
|
var xml = new XmlDocument();
|
||||||
xml.Load("Str.resx");
|
xml.Load("Str.resx");
|
||||||
foreach (XmlNode data in xml.SelectNodes("//root/data")) {
|
foreach (XmlNode data in xml.SelectNodes("//root/data")!) {
|
||||||
#>
|
#>
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <#= data.SelectSingleNode("value").InnerText #>
|
/// <#= data.SelectSingleNode("value")?.InnerText #>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string <#= data.Attributes["name"].Value #> {
|
public static string <#= data.Attributes?["name"].Value #> {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("<#= data.Attributes["name"].Value #>", resourceCulture);
|
return ResourceManager.GetString("<#= data.Attributes!["name"].Value #>", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<#
|
<#
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
namespace Dot;
|
namespace Dot;
|
||||||
|
|
||||||
public abstract class OptionBase : CommandSettings, IOption
|
internal abstract class OptionBase : CommandSettings, IOption
|
||||||
{
|
{
|
||||||
[CommandOption("-k|--keep--session")]
|
[CommandOption("-k|--keep--session")]
|
||||||
[Description(nameof(Str.KeepSession))]
|
[Description(nameof(Str.KeepSession))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
public virtual bool KeepSession { get; set; }
|
public bool KeepSession { get; set; }
|
||||||
}
|
}
|
@ -29,6 +29,6 @@ app.Configure(config => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
|
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
|
||||||
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
|
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
|
||||||
return app.Run(args);
|
return app.Run(args);
|
@ -1,3 +1,5 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
#if NET7_0_WINDOWS
|
#if NET7_0_WINDOWS
|
||||||
using TextCopy;
|
using TextCopy;
|
||||||
@ -8,7 +10,7 @@ namespace Dot.Pwd;
|
|||||||
|
|
||||||
[Description(nameof(Str.RandomPasswordGenerator))]
|
[Description(nameof(Str.RandomPasswordGenerator))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : ToolBase<Option>
|
internal sealed class Main : ToolBase<Option>
|
||||||
{
|
{
|
||||||
private readonly char[][] _charTable = {
|
private readonly char[][] _charTable = {
|
||||||
"0123456789".ToCharArray() //
|
"0123456789".ToCharArray() //
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
namespace Dot.Pwd;
|
namespace Dot.Pwd;
|
||||||
|
|
||||||
public class Option : OptionBase
|
internal class Option : OptionBase
|
||||||
{
|
{
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum GenerateTypes
|
public enum GenerateTypes
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
namespace Dot.Rbom;
|
namespace Dot.Rbom;
|
||||||
|
|
||||||
[Description(nameof(Str.TrimUtf8Bom))]
|
[Description(nameof(Str.TrimUtf8Bom))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : FilesTool<Option>
|
internal sealed class Main : FilesTool<Option>
|
||||||
{
|
{
|
||||||
private readonly byte[] _utf8Bom = { 0xef, 0xbb, 0xbf };
|
private readonly byte[] _utf8Bom = { 0xef, 0xbb, 0xbf };
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
namespace Dot.Rbom;
|
namespace Dot.Rbom;
|
||||||
|
|
||||||
public class Option : DirOption { }
|
internal class Option : DirOption { }
|
@ -1,3 +1,6 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
@ -10,7 +13,7 @@ namespace Dot.Text;
|
|||||||
|
|
||||||
[Description(nameof(Str.TextTool))]
|
[Description(nameof(Str.TextTool))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : ToolBase<Option>
|
internal sealed class Main : ToolBase<Option>
|
||||||
{
|
{
|
||||||
private ref struct Output
|
private ref struct Output
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
namespace Dot.Text;
|
namespace Dot.Text;
|
||||||
|
|
||||||
public class Option : OptionBase
|
internal class Option : OptionBase
|
||||||
{
|
{
|
||||||
[CommandArgument(0, "[input text]")]
|
[CommandArgument(0, "[input text]")]
|
||||||
[Description(nameof(Str.TextTobeProcessed))]
|
[Description(nameof(Str.TextTobeProcessed))]
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
||||||
namespace Dot.Time;
|
namespace Dot.Time;
|
||||||
|
|
||||||
[Description(nameof(Str.TimeTool))]
|
[Description(nameof(Str.TimeTool))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : ToolBase<Option>
|
internal sealed class Main : ToolBase<Option>
|
||||||
{
|
{
|
||||||
private const int _MAX_DEGREE_OF_PARALLELISM = 10;
|
private const int _MAX_DEGREE_OF_PARALLELISM = 10;
|
||||||
private const int _NTP_PORT = 123;
|
private const int _NTP_PORT = 123;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
namespace Dot.Time;
|
namespace Dot.Time;
|
||||||
|
|
||||||
public class Option : OptionBase
|
internal class Option : OptionBase
|
||||||
{
|
{
|
||||||
[CommandOption("-s|--sync")]
|
[CommandOption("-s|--sync")]
|
||||||
[Description(nameof(Str.SyncToLocalTime))]
|
[Description(nameof(Str.SyncToLocalTime))]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace Dot.Time;
|
namespace Dot.Time;
|
||||||
|
|
||||||
public static class ProgressTaskStateExtensions
|
internal static class ProgressTaskStateExtensions
|
||||||
{
|
{
|
||||||
public static TimeSpan Result(this ProgressTaskState me)
|
public static TimeSpan Result(this ProgressTaskState me)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||||
|
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Dot.Time;
|
namespace Dot.Time;
|
||||||
|
|
||||||
public class TaskResultColumn : ProgressColumn
|
internal class TaskResultColumn : ProgressColumn
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the alignment of the task description.
|
/// Gets or sets the alignment of the task description.
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||||
|
|
||||||
|
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
using Spectre.Console.Rendering;
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
namespace Dot.Time;
|
namespace Dot.Time;
|
||||||
|
|
||||||
public class TaskStatusColumn : ProgressColumn
|
internal class TaskStatusColumn : ProgressColumn
|
||||||
{
|
{
|
||||||
public enum Statues : byte
|
public enum Statues : byte
|
||||||
{
|
{
|
||||||
[Description($"[gray]{nameof(Ready)}[/]")]
|
[Description($"[gray]{nameof(Ready)}[/]")]
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
Ready
|
Ready
|
||||||
|
|
||||||
, [Description($"[yellow]{nameof(Connecting)}[/]")]
|
, [Description($"[yellow]{nameof(Connecting)}[/]")]
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
namespace Dot.ToLf;
|
namespace Dot.ToLf;
|
||||||
|
|
||||||
[Description(nameof(Str.ConvertEndOfLineToLF))]
|
[Description(nameof(Str.ConvertEndOfLineToLF))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : FilesTool<Option>
|
internal sealed class Main : FilesTool<Option>
|
||||||
{
|
{
|
||||||
protected override async ValueTask FileHandle(string file, CancellationToken _)
|
protected override async ValueTask FileHandle(string file, CancellationToken _)
|
||||||
{
|
{
|
||||||
@ -11,7 +14,8 @@ public sealed class Main : FilesTool<Option>
|
|||||||
var hasWrote = false;
|
var hasWrote = false;
|
||||||
var isBin = false;
|
var isBin = false;
|
||||||
string tmpFile;
|
string tmpFile;
|
||||||
int data;
|
// ReSharper disable once TooWideLocalVariableScope
|
||||||
|
int data;
|
||||||
|
|
||||||
await using (var fsr = OpenFileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
|
await using (var fsr = OpenFileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
|
||||||
if (fsr is null) {
|
if (fsr is null) {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
namespace Dot.ToLf;
|
namespace Dot.ToLf;
|
||||||
|
|
||||||
public class Option : DirOption { }
|
internal class Option : DirOption { }
|
@ -1,17 +1,10 @@
|
|||||||
namespace Dot;
|
namespace Dot;
|
||||||
|
|
||||||
public abstract class ToolBase<TOption> : Command<TOption> where TOption : OptionBase
|
internal abstract class ToolBase<TOption> : Command<TOption> where TOption : OptionBase
|
||||||
{
|
{
|
||||||
protected TOption Opt { get; private set; }
|
protected TOption Opt { get; private set; }
|
||||||
protected abstract Task Core();
|
protected abstract Task Core();
|
||||||
|
|
||||||
public override int Execute(CommandContext context, TOption option)
|
|
||||||
{
|
|
||||||
Opt = option;
|
|
||||||
Run().Wait();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual async Task Run()
|
protected virtual async Task Run()
|
||||||
{
|
{
|
||||||
await Core();
|
await Core();
|
||||||
@ -20,4 +13,11 @@ public abstract class ToolBase<TOption> : Command<TOption> where TOption : Optio
|
|||||||
AnsiConsole.Console.Input.ReadKey(true);
|
AnsiConsole.Console.Input.ReadKey(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int Execute(CommandContext context, TOption option)
|
||||||
|
{
|
||||||
|
Opt = option;
|
||||||
|
Run().Wait();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,24 +0,0 @@
|
|||||||
namespace Dot;
|
|
||||||
|
|
||||||
public static class ToolsFactory
|
|
||||||
{
|
|
||||||
// public static ITool Create(IOption option)
|
|
||||||
// {
|
|
||||||
// return option switch {
|
|
||||||
// Option o => new Main(o)
|
|
||||||
// , ToLf.Option o => new ToLf.Main(o)
|
|
||||||
// , RmBlank.Option o => new RmBlank.Main(o)
|
|
||||||
// , Pwd.Option o => new Pwd.Main(o)
|
|
||||||
// , Text.Option o => new Text.Main(o)
|
|
||||||
// , Guid.Option o => new Guid.Main(o)
|
|
||||||
// , Time.Option o => new Time.Main(o)
|
|
||||||
// #if NET7_0_WINDOWS
|
|
||||||
// , Color.Option o => new Color.Main(o)
|
|
||||||
// #endif
|
|
||||||
// , IP.Option o => new IP.Main(o)
|
|
||||||
// // , Git.Option o => new Git.Main(o)
|
|
||||||
// , Json.Option o => new Json.Main(o)
|
|
||||||
// , _ => throw new ArgumentOutOfRangeException(nameof(option))
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
}
|
|
@ -1,11 +1,13 @@
|
|||||||
using Dot.RmBlank;
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
|
|
||||||
namespace Dot.Trim;
|
namespace Dot.Trim;
|
||||||
|
|
||||||
[Description(nameof(Str.RemoveTrailingWhiteSpaces))]
|
[Description(nameof(Str.RemoveTrailingWhiteSpaces))]
|
||||||
[Localization(typeof(Str))]
|
[Localization(typeof(Str))]
|
||||||
public sealed class Main : FilesTool<Option>
|
internal sealed class Main : FilesTool<Option>
|
||||||
{
|
{
|
||||||
private static int GetSpacesCnt(Stream fsr)
|
private static int GetSpacesCnt(Stream fsr)
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
namespace Dot.RmBlank;
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
public class Option : DirOption { }
|
|
||||||
|
namespace Dot.Trim;
|
||||||
|
|
||||||
|
internal class Option : DirOption { }
|
@ -1,3 +1,6 @@
|
|||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
// ReSharper disable UnusedMethodReturnValue.Global
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Dot;
|
namespace Dot;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user