Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

"--version option cannot be combined with other arguments." is not displayed when "--help" is also specified

Đang mở
#2,501 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu với việc tái hiện trong Program.cs và chạy các tổ hợp lệnh --help/--version được liệt kê để xác nhận đầu ra khác nhau. Sau đó, theo dõi cách CLI xử lý các đối số help và version; hoàn tất khi lỗi dự kiến "--version option cannot be combined with other arguments." được hiển thị khi cung cấp cả hai tùy chọn.

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

Mô tả

Hi.

Thank you for System.CommandLine.

The error message "--version option cannot be combined with other arguments." is not displayed when "--help" is also specified on the command line.

Steps to reproduce:

  1. Build console app with Program.cs:
internal class Program
{
    static async Task<int> Main(string[] args)
    {
        RootCommand rootCommand = new RootCommand();

        var option = new Option<bool>("--option1");

        rootCommand.Add(option);

        rootCommand.Handler = CommandHandler.Create(() =>
        {
            Console.WriteLine("Hello, World!");
        });

        return await rootCommand.InvokeAsync(args);
    }
}
  1. Run ConsoleApp1.exe --option1 --version
    Notice the error --version option cannot be combined with other arguments.
    This is expected behavior.

  2. Run ConsoleApp10.exe --help --version
    Notice the error is not displayed.
    Only the version is displayed.
    This is unexpected behavior; I expected the error --version option cannot be combined with other arguments..

  3. Run ConsoleApp10.exe --option1 --help --version
    Notice the error is not displayed.
    Only the version is displayed.
    This is unexpected behavior; I expected the error --version option cannot be combined with other arguments..

System.CommandLine 2.0.0-beta4.22272.1

Thank you.

Ngôn ngữ chính
C#
Star
3.7k
Fork
434
Merge trung bình
6 giờ 27 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/command-line-api

Tất cả issue của dotnet/command-line-api

Issue tương tự

Thêm issue về C#

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.