Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#2,746 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Documentazione
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
csharp
Ambito
cli, documentation

Direzione di ricerca

Inizia esaminando README e la cartella samples alla ricerca di esempi esistenti di System.CommandLine e dell’uso di root.AddGlobalOption. Aggiungi un esempio chiaro di un’opzione globale -v/--verbosity che mostri come l’handler legge il valore o applica un valore predefinito, e conferma che l’esempio sia comprensibile come esempio di documentazione autonomo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
C#
Stelle
3.7k
Fork
434
Merge medio
6h 27m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/command-line-api

Tutte le issue di dotnet/command-line-api

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.