test: 补充测试
This commit is contained in:
@@ -26,8 +26,10 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
|
|
||||||
public void CommandLineApplication(CommandLineApplication application)
|
public void CommandLineApplication(CommandLineApplication application)
|
||||||
{
|
{
|
||||||
var templateTypeOption = application.Option("-t|--moduleType", "模板类型", CommandOptionType.SingleValue);
|
var templateTypeOption = application.Option("-t|--moduleType", "模板类型:`module`|`porject`",
|
||||||
var csfOption = application.Option("-csf", "是否创建解决方案", CommandOptionType.SingleValue);
|
CommandOptionType.SingleValue);
|
||||||
|
var pathOption = application.Option("-p|--path", "创建路径", CommandOptionType.SingleValue);
|
||||||
|
var csfOption = application.Option("-csf", "是否创建解决方案文件夹", CommandOptionType.NoValue);
|
||||||
var moduleNameArgument = application.Argument("moduleName", "模块名", (_) => { });
|
var moduleNameArgument = application.Argument("moduleName", "模块名", (_) => { });
|
||||||
|
|
||||||
|
|
||||||
@@ -57,7 +59,13 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
}).Result;
|
}).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
zipPath = $"{id}.zip";
|
var path = string.Empty;
|
||||||
|
if (pathOption.HasValue())
|
||||||
|
{
|
||||||
|
path = pathOption.Value();
|
||||||
|
}
|
||||||
|
|
||||||
|
zipPath = Path.Combine(path, $"{id}.zip");
|
||||||
File.WriteAllBytes(zipPath, fileByteArray);
|
File.WriteAllBytes(zipPath, fileByteArray);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -71,17 +79,19 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
{
|
{
|
||||||
var moduleName = moduleNameArgument.Value.ToLower().Replace(".", "-");
|
var moduleName = moduleNameArgument.Value.ToLower().Replace(".", "-");
|
||||||
|
|
||||||
if (Directory.Exists(moduleName))
|
unzipDirPath = Path.Combine(path, unzipDirPath);
|
||||||
|
if (Directory.Exists(unzipDirPath))
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"文件夹[{moduleName}]已存在,请删除后重试");
|
throw new UserFriendlyException($"文件夹[{unzipDirPath}]已存在,请删除后重试");
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.CreateDirectory(moduleName);
|
Directory.CreateDirectory(unzipDirPath);
|
||||||
unzipDirPath = moduleName;
|
unzipDirPath = moduleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
ZipFile.ExtractToDirectory(zipPath, unzipDirPath);
|
ZipFile.ExtractToDirectory(zipPath, unzipDirPath);
|
||||||
//创建压缩包后删除临时目录
|
//创建压缩包后删除临时目录
|
||||||
File.Delete(zipPath);
|
File.Delete(zipPath);
|
||||||
|
|||||||
@@ -21,12 +21,18 @@ class Program
|
|||||||
|
|
||||||
//帮助
|
//帮助
|
||||||
//args = ["-h"];
|
//args = ["-h"];
|
||||||
|
|
||||||
//版本
|
//版本
|
||||||
// args = ["-v"];
|
// args = ["-v"];
|
||||||
|
|
||||||
//清理
|
//清理
|
||||||
// args = ["clear"];
|
// args = ["clear"];
|
||||||
|
|
||||||
|
//创建模块
|
||||||
|
args = ["new","oooo", "-t","module","-p","D:\\temp","-csf"];
|
||||||
|
|
||||||
//添加模块
|
//添加模块
|
||||||
args = ["add-module", "kkk"];
|
//args = ["add-module", "kkk"];
|
||||||
#endif
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user