问题描述
我正在使用“CommandDotNet”在 CLI 工具中创建命令。而且我还添加了 [SubCommand]
属性但是“set”命令或其子命令“workdir”不起作用。以前添加的子命令工作正常。可能是什么问题?
CLITool.cs
[SubCommand]
public Configurations Set { get; set; }
Configurations.cs
[Command(Description = "Use for additional configuration commands.")]
public class Configurations
{
private static string configFile = FilePathUtility.workdirectory;
[DefaultMethod]
public void SetDefaultCommand()
{
string workdir = File.ReadAllText(configFile);
if (!string.IsNullOrWhiteSpace(workdir))
{
FeedbackUtility.output($"Working directory : {workdir}",ColorUtility.colorsettings.INFO);
}else { FeedbackUtility.output($"Working directory has not set. Use \"clitool set workdir\" to set the working directory",ColorUtility.colorsettings.INFO); }
}
[Command(Description = "Set working directory")]
public async Task workdir()
{
Console.WriteLine("\nSpecify working directory:");
string workdir = Console.ReadLine();
//Overwrites/Creates config file in temp folder with working directory string
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\temp\\");
File.WriteallText(configFile,workdir);
FeedbackUtility.output("Successfully specified the working directory!",ColorUtility.colorsettings.SUCCESS);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)