feat:搭建yi-abp tool框架

This commit is contained in:
橙子
2024-06-02 13:09:25 +08:00
parent daaa3513ae
commit cbc34ade78
35 changed files with 822 additions and 9 deletions

View File

@@ -62,7 +62,7 @@ namespace Yi.Abp.Tool
}
await commandOrNull.InvokerAsync(options);
await commandOrNull.InvokerAsync(options,args);
}
/// <summary>

View File

@@ -11,7 +11,7 @@ namespace Yi.Abp.Tool.Commands
{
public List<string> CommandStrs => new List<string> { "h", "help", "-h", "-help" };
public Task InvokerAsync(Dictionary<string, string> options)
public Task InvokerAsync(Dictionary<string, string> options, string[] args)
{
string? errorMsg = null;
if (options.TryGetValue("error", out _))

View File

@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Yi.Abp.Tool.Application.Contracts;
using Yi.Abp.Tool.Application.Contracts.Dtos;
namespace Yi.Abp.Tool.Commands
{
public class NewCommand : ICommand
{
private readonly ITemplateGenService _templateGenService;
public NewCommand(ITemplateGenService templateGenService)
{
_templateGenService = templateGenService;
}
public List<string> CommandStrs => new List<string>() { "new" };
public async Task InvokerAsync(Dictionary<string, string> options, string[] args)
{
//只有一个new
if (args.Length <= 1)
{
throw new UserFriendlyException("命令错误new命令后必须添加 名称");
}
string name = args[1];
options.TryGetValue("t", out var templateType);
if (templateType == "module")
{
//代表模块生成
var fileResult = await _templateGenService.CreateModuleAsync(new TemplateGenCreateInputDto
{
Name = name,
});
var fileContent = fileResult as FileContentResult;
File.WriteAllText("./", Encoding.UTF8.GetString(fileContent.FileContents));
}
else
{
//暂未实现
throw new NotImplementedException();
//代表模块生成
var fileResult = await _templateGenService.CreateProjectAsync(new TemplateGenCreateInputDto
{
Name = name,
});
}
}
}
}

View File

@@ -4,7 +4,7 @@
{
public List<string> CommandStrs => new List<string> { "version", "v", "-version", "-v" };
public Task InvokerAsync(Dictionary<string, string> options)
public Task InvokerAsync(Dictionary<string, string> options, string[] args)
{
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Console.WriteLine($"Yi-ABP TOOL {version}");

View File

@@ -18,6 +18,6 @@ namespace Yi.Abp.Tool
/// 执行
/// </summary>
/// <returns></returns>
public Task InvokerAsync(Dictionary<string,string> options);
public Task InvokerAsync(Dictionary<string,string> options, string[] args);
}
}

View File

@@ -15,6 +15,7 @@ class Program
//args = ["-h"];
//args = [];
//args = ["12312"];
args = ["new", "Acme.Book","-t", "module", "-csf"];
#endif
try
{
@@ -34,6 +35,7 @@ class Program
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
Console.ReadKey();
}
}

View File

@@ -31,6 +31,11 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Abp.Tool.HttpApi.Client\Yi.Abp.Tool.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="readme.md">
<Pack>True</Pack>

View File

@@ -3,9 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Abp.Tool.HttpApi.Client;
namespace Yi.Abp.Tool
{
[DependsOn(typeof(YiAbpToolHttpApiClientModule))]
public class YiAbpToolModule : AbpModule
{
}