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

Add a “Global verbosity option” example to README / documentation

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

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/100
Loại issue
Tài liệu
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
cli, documentation

Hướng nghiên cứu

Bắt đầu bằng cách xem lại README và thư mục samples để tìm các ví dụ System.CommandLine hiện có cũng như cách sử dụng root.AddGlobalOption. Thêm một ví dụ rõ ràng về tùy chọn global -v/--verbosity, cho thấy handler đọc giá trị hoặc áp dụng giá trị mặc định như thế nào, và xác nhận rằng ví dụ này dễ hiểu khi đứng độc lập như một mẫu tài liệu.

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

Mô tả

Area-Documentation
Description
Type of issue

Feature request / documentation sample

Description

Many CLI tools follow a pattern where a global --verbosity (short -v) option controls log or output verbosity across all subcommands.
Currently, README and docs do not have a clear example showing how to implement this using System.CommandLine.

Suggested improvement

Add a sample to README or samples folder demonstrating:

var verbosity = new Option<string>(new [] { "-v", "--verbosity" }, "Set verbosity");
root.AddGlobalOption(verbosity);
// ... handler that reads verbosity value or sets default if no value given

### Reproduction Steps

### Type of issue  
Feature request / documentation sample

### Description  
Many CLI tools follow a pattern where a global --verbosity (short -v) option controls log or output verbosity across all subcommands.  
Currently, README and docs do not have a clear example showing how to implement this using System.CommandLine.

### Suggested improvement  
Add a sample to README or samples folder demonstrating:

```csharp
var verbosity = new Option<string>(new [] { "-v", "--verbosity" }, "Set verbosity");
root.AddGlobalOption(verbosity);
// ... handler that reads verbosity value or sets default if no value given

### Expected behavior

The SDK should locate global.json starting from:
 The solution directory (if a .sln exists),
 Else the project directory (if a .csproj exists),
Else the current working directory.
Then it should search parent folders upward and use the first global.json found to determine the SDK version.

### Actual behavior

The SDK currently starts searching for global.json from the current working directory only,
without first checking for a solution or project directory.
As a result, running dotnet build or dotnet restore from subfolders may ignore the intended global.json at the solution level.
This leads to unexpected SDK versions being used in multi-project setups.

### Regression?

The SDK currently starts searching for global.json from the current working directory only,
without first checking for a solution or project directory.
As a result, running dotnet build or dotnet restore from subfolders may ignore the intended global.json at the solution level.
This leads to unexpected SDK versions being used in multi-project setups.

### Known Workarounds

The SDK currently starts searching for global.json from the current working directory only,
without first checking for a solution or project directory.
As a result, running dotnet build or dotnet restore from subfolders may ignore the intended global.json at the solution level.
This leads to unexpected SDK versions being used in multi-project setups.

### Configuration

The SDK currently starts searching for global.json from the current working directory only,
without first checking for a solution or project directory.
As a result, running dotnet build or dotnet restore from subfolders may ignore the intended global.json at the solution level.
This leads to unexpected SDK versions being used in multi-project setups.

### Other information

The SDK currently starts searching for global.json from the current working directory only,
without first checking for a solution or project directory.
As a result, running dotnet build or dotnet restore from subfolders may ignore the intended global.json at the solution level.
This leads to unexpected SDK versions being used in multi-project setups.
Ngôn ngữ chính
C#
Star
3.7k
Fork
434
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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.