dotnet / dotnet/command-line-api

Add built-in example for defining a global --verbosity / -v option

Open
#2,744 1 comment 2 reactions 0 assignees View on GitHub
Area-Documentation
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

### Type of issue
Feature request / documentation enhancement

### Description
System.CommandLine already supports global options, but there’s no sample showing
how to define a global `--verbosity` (`-v`) option that applies to all subcommands
and defaults to `Diagnostic` when specified without a value.

### Suggested improvement
Add a short example to the README or samples folder demonstrating:

```csharp
var verbosity = new Option(
new[] { "-v", "--verbosity" },
"Set output verbosity (quiet, minimal, normal, detailed, diagnostic)")
{
Arity = ArgumentArity.ZeroOrOne
};
root.AddGlobalOption(verbosity);
Why this helps

--verbosity is a standard .NET CLI pattern, so showing how to implement it helps developers align their own tools with .NET conventions.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.