Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#2,746 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
文档
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp
领域
cli, documentation

调研方向

首先查看 README 和 samples 文件夹,了解现有的 System.CommandLine 示例以及 root.AddGlobalOption 的使用方式。添加一个清晰的全局 -v/--verbosity 选项示例,展示 handler 如何读取该值或应用默认值,并确认该示例作为独立的文档示例是易于理解的。

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
C#
星标
3.7k
派生
434
平均合并
6 小时 27 分钟
30 天内合并 PR
2

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dotnet/command-line-api 的其他 Issue

查看 dotnet/command-line-api 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。