refactor: 重构tool工具
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.CommandLineUtils;
|
||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.DependencyInjection;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
@@ -17,52 +18,66 @@ namespace Yi.Abp.Tool
|
|||||||
}
|
}
|
||||||
public async Task SelectorAsync(string[] args)
|
public async Task SelectorAsync(string[] args)
|
||||||
{
|
{
|
||||||
//不指定命令,默认给help
|
var app = new CommandLineApplication();
|
||||||
if (args.Length == 0)
|
|
||||||
{
|
|
||||||
await SelectorDefaultCommandAsync();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var commandStr = args[0];
|
|
||||||
|
|
||||||
var commandOrNull = _commands.Where(x => x.CommandStrs.Select(x => x.ToUpper()).Contains(commandStr.ToUpper())).FirstOrDefault();
|
// //1-设置命令
|
||||||
|
// app.Command();
|
||||||
//没有匹配到命令,,默认给help
|
// //2-各自命令内,设置选项
|
||||||
if (commandOrNull == null)
|
// app.Options();
|
||||||
{
|
// //3-执行,暴露方法
|
||||||
await SelectorDefaultCommandAsync();
|
// app.Execute(args);
|
||||||
return;
|
|
||||||
}
|
//
|
||||||
|
// //不指定命令,默认给help
|
||||||
var options = new Dictionary<string, string?>();
|
// if (args.Length == 0)
|
||||||
|
// {
|
||||||
//去除命令,剩下进行参数装载
|
// await SelectorDefaultCommandAsync();
|
||||||
string[] commonArgs = args.Skip(1).ToArray();
|
// return;
|
||||||
for (var i = 0; i < commonArgs.Length; i++)
|
// }
|
||||||
{
|
// var app = new CommandLineApplication();
|
||||||
var currentArg = commonArgs[i];
|
//
|
||||||
//命令参数以-或者--开头
|
// var commandStr = args[0];
|
||||||
if (IsCommandArg(currentArg))
|
//
|
||||||
{
|
// var commandOrNull = _commands.Where(x => x.CommandStrs.Select(x => x.ToUpper()).Contains(commandStr.ToUpper())).FirstOrDefault();
|
||||||
string? commonValue = null;
|
//
|
||||||
//参数值在他的下一位
|
// //没有匹配到命令,,默认给help
|
||||||
if (i + 1 < commonArgs.Length)
|
// if (commandOrNull == null)
|
||||||
{
|
// {
|
||||||
var nextArg = commonArgs[i + 1];
|
// await SelectorDefaultCommandAsync();
|
||||||
if (!IsCommandArg(nextArg))
|
// return;
|
||||||
{
|
// }
|
||||||
commonValue = nextArg;
|
//
|
||||||
}
|
// var command = commandOrNull;
|
||||||
|
//
|
||||||
}
|
// var options = new Dictionary<string, string?>();
|
||||||
//删除-就是参数名
|
//
|
||||||
options.Add(ArgToCommandMap(currentArg), commonValue);
|
// //去除命令,剩下进行参数装载
|
||||||
}
|
// string[] commonArgs = args.Skip(1).ToArray();
|
||||||
|
// for (var i = 0; i < commonArgs.Length; i++)
|
||||||
|
// {
|
||||||
|
// var currentArg = commonArgs[i];
|
||||||
}
|
// //命令参数以-或者--开头
|
||||||
await commandOrNull.InvokerAsync(options,args);
|
// if (IsCommandArg(currentArg))
|
||||||
|
// {
|
||||||
|
// string? commonValue = null;
|
||||||
|
// //参数值在他的下一位
|
||||||
|
// if (i + 1 < commonArgs.Length)
|
||||||
|
// {
|
||||||
|
// var nextArg = commonArgs[i + 1];
|
||||||
|
// if (!IsCommandArg(nextArg))
|
||||||
|
// {
|
||||||
|
// commonValue = nextArg;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// //删除-就是参数名
|
||||||
|
// options.Add(ArgToCommandMap(currentArg), commonValue);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// await command.InvokerAsync(options,args);
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
|
||||||
<PackageReference Include="Volo.Abp.Autofac" Version="$(AbpVersion)" />
|
<PackageReference Include="Volo.Abp.Autofac" Version="$(AbpVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user