feat: 完成tool

This commit is contained in:
chenchun
2024-11-08 12:35:54 +08:00
parent e832921edf
commit f3c5d0862b
7 changed files with 21 additions and 30 deletions

View File

@@ -11,29 +11,31 @@ namespace Yi.Abp.Tool.Commands
public class AddModuleCommand : ICommand
{
public string Command => "add-module";
public string? Description { get; }
public string? Description => "将内容添加到当前解决方案` yi-abp add-module <moduleName> [-p <path>] [-s <solution>] ";
public void CommandLineApplication(CommandLineApplication application)
{
application.HelpOption("-h|--help");
var modulePathOption= application.Option("-p|--modulePath", "模块路径",CommandOptionType.SingleValue);
var solutionOption= application.Option("-s|--solution", "解决方案路径",CommandOptionType.SingleValue);
var moduleNameArgument = application.Argument("moduleName", "模块名", (_) => { });
application.OnExecute(() =>
{
var modulePath = "";
var moduleName = moduleNameArgument.Value;
//模块路径默认按小写规则,当前路径
//模块路径默认按小写规则,默认在模块路径下一层
var modulePath =moduleName.ToLower().Replace(".", "-");
if (modulePathOption.HasValue())
{
modulePath = moduleName.ToLower().Replace(".", "-");
modulePath = modulePathOption.Value();
}
//解决方案默认在模块文件夹上一级也可以通过s进行指定
var slnPath = string.Empty;
var slnPath = "../";
if (!solutionOption.HasValue())
if (solutionOption.HasValue())
{
slnPath = "../";
slnPath = solutionOption.Value();
}
CheckFirstSlnPath(slnPath);

View File

@@ -17,6 +17,7 @@ namespace Yi.Abp.Tool.Commands
public void CommandLineApplication(CommandLineApplication application)
{
application.HelpOption("-h|--help");
List<string> delDirBlacklist = ["obj", "bin"];
var pathOption= application.Option("-path", "路径",CommandOptionType.SingleValue);

View File

@@ -10,19 +10,17 @@ namespace Yi.Abp.Tool.Commands
{
public class CloneCommand : ICommand
{
public List<string> CommandStrs => new List<string> { "clone"};
private const string cloneAddress= "https://gitee.com/ccnetcore/Yi";
private const string CloneAddress= "https://gitee.com/ccnetcore/Yi";
public string Command => "clone";
public string? Description => "克隆最新YiFramework源代码";
public string? Description => "克隆最新YiFramework源代码需依赖git";
public void CommandLineApplication(CommandLineApplication application)
{
application.OnExecute(() =>
{
StartCmd($"git clone {cloneAddress}");
StartCmd($"git clone {CloneAddress}");
return 0;
});
}

View File

@@ -22,10 +22,12 @@ namespace Yi.Abp.Tool.Commands
public string Command => "new";
public string? Description => "创建一个模板";
public string? Description => "创建项目模板` yi-abp new <name> -csf `";
public void CommandLineApplication(CommandLineApplication application)
{
application.HelpOption("-h|--help");
var templateTypeOption = application.Option("-t|--template", "模板类型:`module`|`porject`",
CommandOptionType.SingleValue);
var pathOption = application.Option("-p|--path", "创建路径", CommandOptionType.SingleValue);
@@ -35,7 +37,7 @@ namespace Yi.Abp.Tool.Commands
CommandOptionType.SingleValue);
var moduleNameArgument = application.Argument("moduleName", "模块名", (_) => { });
//子命令new list
application.Command("list",(applicationlist) =>
{

View File

@@ -1,14 +0,0 @@
// namespace Yi.Abp.Tool.Commands
// {
// public class VersionCommand : ICommand
// {
// public List<string> CommandStrs => new List<string> { "version", "v", "-version", "-v" };
//
// public Task InvokerAsync(Dictionary<string, string> options, string[] args)
// {
// var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
// Console.WriteLine($"Yi-ABP TOOL {version}");
// return Task.CompletedTask;
// }
// }
// }

View File

@@ -23,7 +23,9 @@ class Program
//查看模板列表
//args = ["new","list"];
//查看子命令帮组
// args = ["new","-h"];
//添加模块
//args = ["add-module", "kkk"];
#endif

View File

@@ -5,7 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.0.1</Version>
<Version>2.0.4</Version>
<Authors>橙子老哥</Authors>
<Description>yi-framework框架配套工具</Description>
<PackageProjectUrl>https://ccnetcore.com</PackageProjectUrl>