commandlineparser / commandlineparser/commandline

--help not quitting program.

Đang mở
#845 0 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
4.8k
Fork
478
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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; }
}
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện hành vi với thiết lập Parser.Default.ParseArguments(args) được示 và các đối số --help hoặc --version đơn lẻ. Theo dõi cách đầu ra trợ giúp và phiên bản được xử lý, sau đó xác minh rằng tiến trình thoát sau khi hiển thị một trong hai thông báo mà không ảnh hưởng đến việc phân tích cú pháp tùy chọn thông thường.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.