feat: 搭建tool

This commit is contained in:
chenchun
2024-11-05 18:50:15 +08:00
parent 9aaa88ef51
commit c944bd3b0e
11 changed files with 433 additions and 489 deletions

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.CommandLineUtils;
using Volo.Abp.DependencyInjection;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Yi.Abp.Tool
{
public class CommandInvoker : ISingletonDependency
{
private readonly IEnumerable<ICommand> _commands;
private CommandLineApplication Application { get; }
public CommandInvoker(IEnumerable<ICommand> commands)
{
_commands = commands;
Application = new CommandLineApplication();
InitCommand();
}
private void InitCommand()
{
Application.HelpOption("-h");
foreach (var command in _commands)
{
Application.Command(command.Command, con => command.CommandLineApplicationAsync(con).Wait());
}
}
public async Task InvokerAsync(string[] args)
{
//使用哪个命令根据第一参数来判断如果都不是打印help
// foreach (var commandLineApplication in Application.Commands)
// {
// commandLineApplication.Execute(args);
// }
Application.Execute(args);
}
}
}