commandlineparser / commandlineparser/commandline
--help not quitting program.
- 主要语言
- C#
- 星标
- 4.8k
- 派生
- 478
- PR 合并指标
- 30 天内没有已合并 PR
描述
calling my console app with single parameter --help or --version is showing the help/version, but then not quitting the app. It continues to run. My setup code is as follows:
```
var result = Parser.Default.ParseArguments(args)
.WithParsed(o =>
{
if (o.Dest != null && o.Dest.Trim() != "")
{
rootOutputFolder = o.Dest.Trim();
}
else
{
// default to current folder's converted_databases/ subfolder
string? currentFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (currentFolder == null)
{
throw new Exception("Could not get current folder");
}
rootOutputFolder = Path.Combine(currentFolder, "converted_databases");
if (!Directory.Exists(rootOutputFolder))
{
DirectoryInfo di = Directory.CreateDirectory(rootOutputFolder);
}
}
if (o.Verbose)
{
db.DoLog = true;
Logger.DoOleLog = true;
}
});
public class Options
{
[Option('d', "dest", Required = false, HelpText = "Full path to root output folder for converted databases. If not specified, will default to .\\converted_databases\\")]
public string? Dest { get; set; }
[Option('v', "verbose", Required = false, HelpText = "Log all SQL queries in converter.log.")]
public bool Verbose { get; set; }
}
```
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先,使用所示的 Parser.Default.ParseArguments(args) 设置以及单独的 --help 或 --version 参数重现该行为。跟踪 help 和 version 输出的处理方式,然后验证进程在显示任一消息后退出,且不会影响正常的选项解析。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100