Class TigerCliCommandGroupBuilder
Configures a command group: a command-path prefix that owns a set of child
commands. The group name is chosen by the consuming app, and a reusable command
library can populate the same group, including inherited provider and environment-variable help
metadata, via a static helper that takes a
TigerCliCommandGroupBuilder.
public sealed class TigerCliCommandGroupBuilder
- Inheritance
-
TigerCliCommandGroupBuilder
- Inherited Members
Remarks
A command registered on a group behaves exactly like a normal command whose path
is the group name followed by the command name:
group.AddCommand<T>("list")
on a group named connections registers the path connections list.
The internal model is path-based, so nested groups (added via
AddCommandGroup(string, Action<TigerCliCommandGroupBuilder>)) resolve, bind, and execute exactly like directly
registered full-path commands.Methods
AddAsyncProvider(string, Func<TigerCliProviderContext, Task<IReadOnlyList<string>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers an async group-level string provider inherited by child commands. Prefer this over
the sync
AddProvider(string, Func<TigerCliProviderContext, IReadOnlyList<string>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
for slow or I/O-backed providers; observe CancellationToken
to make the work cooperatively cancellable, and use
configure to customize the
loading message.public TigerCliCommandGroupBuilder AddAsyncProvider(string key, Func<TigerCliProviderContext, Task<IReadOnlyList<string>>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null)
Parameters
keystringproviderFunc<TigerCliProviderContext, Task<IReadOnlyList<string>>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
AddAsyncProvider<TValue>(string, Func<TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers an async group-level named provider inherited by child commands. Prefer this over the
sync overload for slow or I/O-backed providers; observe
CancellationToken to make the work cooperatively cancellable,
and use
configure to customize the loading message.public TigerCliCommandGroupBuilder AddAsyncProvider<TValue>(string key, Func<TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null)
Parameters
keystringproviderFunc<TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
Type Parameters
TValue
AddAsyncProvider<TSettings, TValue>(string, Func<TSettings, TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers an async group-level named provider that can read partially bound settings. Prefer
this over the sync overload for slow or I/O-backed providers; observe
CancellationToken to make the work cooperatively cancellable,
and use
configure to customize the loading message.public TigerCliCommandGroupBuilder AddAsyncProvider<TSettings, TValue>(string key, Func<TSettings, TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null) where TSettings : TigerCliSettings
Parameters
keystringproviderFunc<TSettings, TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
Type Parameters
TSettingsTValue
AddCommandGroup(string, Action<TigerCliCommandGroupBuilder>)
Registers a nested command group under this group.
name is
relative to this group; the resolved group path is this group's path followed by
name. Commands and further subgroups added through
configure resolve, bind, prompt and execute exactly as if their
full path had been registered directly — nesting is a help/menu and configuration
convenience, not a separate dispatch path. Group-level prompt mode, providers and
command-menu opinion cascade to descendants; a nearer group overrides a farther one.public TigerCliCommandGroupBuilder AddCommandGroup(string name, Action<TigerCliCommandGroupBuilder> configure)
Parameters
namestringconfigureAction<TigerCliCommandGroupBuilder>
Returns
AddCommand<TCommand>(string, Action<TigerCliCommandBuilder>?, string?, string?)
Registers a child command created with its parameterless constructor and
configures metadata for that command registration.
public TigerCliCommandGroupBuilder AddCommand<TCommand>(string name, Action<TigerCliCommandBuilder>? configure, string? description = null, string? descriptionResourceKey = null) where TCommand : class, new()
Parameters
namestringconfigureAction<TigerCliCommandBuilder>descriptionstringdescriptionResourceKeystring
Returns
Type Parameters
TCommand
Exceptions
- ArgumentException
nameis not a single token — nest deeper paths under AddCommandGroup(string, Action<TigerCliCommandGroupBuilder>) instead of a multi-token name.
AddCommand<TCommand>(string, Func<TCommand>, Action<TigerCliCommandBuilder>?, string?, string?)
Registers a child command created by
factory and configures
metadata for that command registration.public TigerCliCommandGroupBuilder AddCommand<TCommand>(string name, Func<TCommand> factory, Action<TigerCliCommandBuilder>? configure, string? description = null, string? descriptionResourceKey = null) where TCommand : class
Parameters
namestringfactoryFunc<TCommand>configureAction<TigerCliCommandBuilder>descriptionstringdescriptionResourceKeystring
Returns
Type Parameters
TCommand
Exceptions
- ArgumentException
nameis not a single token — nest deeper paths under AddCommandGroup(string, Action<TigerCliCommandGroupBuilder>) instead of a multi-token name.
AddCommand<TCommand>(string, Func<TCommand>, string?, string?)
Registers a child command created by
factory. Command
factories let reusable command libraries pass services or options into a command
without requiring a DI container in the consuming app.public TigerCliCommandGroupBuilder AddCommand<TCommand>(string name, Func<TCommand> factory, string? description = null, string? descriptionResourceKey = null) where TCommand : class
Parameters
Returns
Type Parameters
TCommand
Exceptions
- ArgumentException
nameis not a single token — nest deeper paths under AddCommandGroup(string, Action<TigerCliCommandGroupBuilder>) instead of a multi-token name.
AddCommand<TCommand>(string, string?, string?)
Registers a child command created with its parameterless constructor.
name is relative to the group; the resolved command path is
the group name followed by name.public TigerCliCommandGroupBuilder AddCommand<TCommand>(string name, string? description = null, string? descriptionResourceKey = null) where TCommand : class, new()
Parameters
Returns
Type Parameters
TCommand
Exceptions
- ArgumentException
nameis not a single token — nest deeper paths under AddCommandGroup(string, Action<TigerCliCommandGroupBuilder>) instead of a multi-token name.
AddEnvironmentVariable(string, string)
Adds group-level help metadata for an environment variable recognized by this group and its
descendant commands. TigerCli displays it in applicable
--help-env output; it does not
read, parse, or apply the variable.public TigerCliCommandGroupBuilder AddEnvironmentVariable(string name, string description)
Parameters
namestring- The environment variable name.
descriptionstring- The help description. TigerCli markup is supported.
Returns
- TigerCliCommandGroupBuilder
- This builder for chaining.
Exceptions
- ArgumentException
nameordescriptionis null, empty, or whitespace, ornamecontains whitespace.- InvalidOperationException
nameduplicates another variable on this group.
AddProvider(string, Func<TigerCliProviderContext, IReadOnlyList<string>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers a sync group-level string provider inherited by child commands; each returned
string is used as both value and label. Prefer the async overloads for slow or I/O-backed
providers.
public TigerCliCommandGroupBuilder AddProvider(string key, Func<TigerCliProviderContext, IReadOnlyList<string>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null)
Parameters
keystringproviderFunc<TigerCliProviderContext, IReadOnlyList<string>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
Exceptions
- ArgumentException
keyis null, empty, or whitespace.- ArgumentNullException
providerisnull.
AddProvider(string, Func<TigerCliProviderContext, Task<IReadOnlyList<string>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers an async group-level string provider inherited by child commands; each returned
string is used as both value and label. Equivalent to
AddAsyncProvider(string, Func<TigerCliProviderContext, Task<IReadOnlyList<string>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?),
which is the preferred spelling for new code.
public TigerCliCommandGroupBuilder AddProvider(string key, Func<TigerCliProviderContext, Task<IReadOnlyList<string>>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null)
Parameters
keystringproviderFunc<TigerCliProviderContext, Task<IReadOnlyList<string>>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
Exceptions
- ArgumentException
keyis null, empty, or whitespace.- ArgumentNullException
providerisnull.
AddProvider<TValue>(string, Func<TigerCliProviderContext, IReadOnlyList<OptionItem<TValue>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers a sync group-level named provider inherited by child commands, returning
key/label pairs (OptionItem<TKey>). Prefer the async overloads for slow or
I/O-backed providers.
public TigerCliCommandGroupBuilder AddProvider<TValue>(string key, Func<TigerCliProviderContext, IReadOnlyList<OptionItem<TValue>>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null)
Parameters
keystringproviderFunc<TigerCliProviderContext, IReadOnlyList<OptionItem<TValue>>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
Type Parameters
TValue
Exceptions
- ArgumentException
keyis null, empty, or whitespace.- ArgumentNullException
providerisnull.
AddProvider<TValue>(string, Func<TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers an async group-level named provider inherited by child commands, returning
key/label pairs (OptionItem<TKey>). Equivalent to the
AddAsyncProvider spelling, which is preferred for new code.public TigerCliCommandGroupBuilder AddProvider<TValue>(string key, Func<TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null)
Parameters
keystringproviderFunc<TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
Type Parameters
TValue
Exceptions
- ArgumentException
keyis null, empty, or whitespace.- ArgumentNullException
providerisnull.
AddProvider<TSettings, TValue>(string, Func<TSettings, TigerCliProviderContext, IReadOnlyList<OptionItem<TValue>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers a sync group-level named provider that additionally receives the partially bound
settings instance. Inherited by child commands. Prefer the async overloads for slow or
I/O-backed providers.
public TigerCliCommandGroupBuilder AddProvider<TSettings, TValue>(string key, Func<TSettings, TigerCliProviderContext, IReadOnlyList<OptionItem<TValue>>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null) where TSettings : TigerCliSettings
Parameters
keystringproviderFunc<TSettings, TigerCliProviderContext, IReadOnlyList<OptionItem<TValue>>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
Type Parameters
TSettingsTValue
Exceptions
- ArgumentException
keyis null, empty, or whitespace.- ArgumentNullException
providerisnull.
AddProvider<TSettings, TValue>(string, Func<TSettings, TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers an async group-level named provider that additionally receives the partially
bound settings instance, letting the choices depend on values supplied earlier in the run.
Inherited by child commands. Equivalent to the
AddAsyncProvider spelling, which is
preferred for new code.public TigerCliCommandGroupBuilder AddProvider<TSettings, TValue>(string key, Func<TSettings, TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>> provider, IEnumerable<string>? dependsOn = null, Action<TigerCliProviderOptions>? configure = null) where TSettings : TigerCliSettings
Parameters
keystringproviderFunc<TSettings, TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>dependsOnIEnumerable<string>configureAction<TigerCliProviderOptions>
Returns
Type Parameters
TSettingsTValue
Exceptions
- ArgumentException
keyis null, empty, or whitespace.- ArgumentNullException
providerisnull.
CommandMenu(CommandMenuMode)
Sets the group's command-menu opinion, inherited by child commands that do not set their own.
Disabled hides the whole group (and its children) from the menu;
Enabled opts the group's children in (unless a child overrides
with Disabled).
public TigerCliCommandGroupBuilder CommandMenu(CommandMenuMode mode)
Parameters
modeCommandMenuMode
Returns
SetDescription(string, string?)
Sets the group description. It is shown next to the group in top-level help
and as the heading of the group's own help. The description may contain
TigerCli markup.
public TigerCliCommandGroupBuilder SetDescription(string description, string? resourceKey = null)
Parameters
descriptionstring- Fallback description used when no resource key is provided or when the key fails to resolve.
resourceKeystring- Optional resource key resolved through the app
ResourceManagerregistered viaUseAppResourcesagainst the active run culture. Missing keys silently fall back todescription.
Returns
SetPromptMode(TigerCliPromptMode)
Sets the prompt mode inherited by child commands that do not define their own
command-level prompt mode.
public TigerCliCommandGroupBuilder SetPromptMode(TigerCliPromptMode mode)
Parameters
modeTigerCliPromptMode