System.CommandLine.StaticCompletions 3.0.0-rc.1.26425.128

Prefix Reserved
This is a prerelease version of System.CommandLine.StaticCompletions.
dotnet add package System.CommandLine.StaticCompletions --version 3.0.0-rc.1.26425.128
                    
NuGet\Install-Package System.CommandLine.StaticCompletions -Version 3.0.0-rc.1.26425.128
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="System.CommandLine.StaticCompletions" Version="3.0.0-rc.1.26425.128" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="System.CommandLine.StaticCompletions" Version="3.0.0-rc.1.26425.128" />
                    
Directory.Packages.props
<PackageReference Include="System.CommandLine.StaticCompletions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add System.CommandLine.StaticCompletions --version 3.0.0-rc.1.26425.128
                    
#r "nuget: System.CommandLine.StaticCompletions, 3.0.0-rc.1.26425.128"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package System.CommandLine.StaticCompletions@3.0.0-rc.1.26425.128
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=System.CommandLine.StaticCompletions&version=3.0.0-rc.1.26425.128&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=System.CommandLine.StaticCompletions&version=3.0.0-rc.1.26425.128&prerelease
                    
Install as a Cake Tool

System.CommandLine.StaticCompletions

System.CommandLine.StaticCompletions generates static shell completion scripts from a System.CommandLine Command tree. It walks your command hierarchy - commands, subcommands, options, arguments, and aliases - and emits a native completion script for the user's shell.

These scripts are "static" because they describe the shape of your CLI ahead of time and can be shipped, checked in, or installed by a package manager. Unlike the default dotnet-suggest integration, they don't require a separate global tool to be installed to provide completions for the fixed parts of your CLI. Where you genuinely need runtime values (for example, completing a name looked up from a database), individual symbols can opt into dynamic completions that call back into your application.

Supported shells:

  • Bash (bash)
  • Zsh (zsh)
  • PowerShell / PowerShell Core (pwsh)
  • Fish (fish)
  • Nushell (nushell)

Getting Started

Add a completions command to your application's root command. The CompletionsCommandDefinition provides the completions script <shell> command, and CompletionsCommandParser.ConfigureCommand wires up the action that produces the script:

using System.CommandLine;
using System.CommandLine.StaticCompletions;

RootCommand rootCommand = new("My application");

// ... add your options, arguments, and subcommands ...

// Add the `completions` command to your CLI.
CompletionsCommandDefinition completionsCommand = new();
CompletionsCommandParser.ConfigureCommand(completionsCommand);
rootCommand.Subcommands.Add(completionsCommand);

return rootCommand.Parse(args).Invoke();

Your users can now generate a completion script for their shell:

# Generate a script for a specific shell
> myapp completions script bash > ~/.local/share/bash-completion/completions/myapp

# The shell argument is optional - it defaults to the current shell
> myapp completions script >> $PROFILE

When the shell argument is omitted, the shell is detected from the environment (the SHELL variable on Unix, PowerShell on Windows).

Dynamic Completions

Static scripts are perfect for the fixed structure of your CLI, but some completions can only be computed at runtime. Mark an option or argument as dynamic and the generated script will call back into your application (via System.CommandLine's built-in [suggest] directive) to resolve those values on demand:

using System.CommandLine;
using System.CommandLine.StaticCompletions;

Option<string> nameOption = new("--name")
{
    Description = "A name resolved at completion time"
};

// Values will be resolved by invoking the app at completion time.
nameOption.IsDynamic = true;
nameOption.CompletionSources.Add(_ => GetNamesFromDatabase());

rootCommand.Options.Add(nameOption);

Note: Dynamic completions rely on the [suggest] directive being present on your root command (it is enabled by default). If you have removed it while dynamic symbols are present, script generation will emit a warning because those completions would silently do nothing.

Framework Support

  • .NET 8.0+ - Trimming and AOT compatible.

License

This package is licensed under the MIT License.

Documentation

Support

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-rc.1.26425.128 142 9/8/2026
3.0.0-preview.7.26381.103 83 8/11/2026