Table of Contents

Class TigerCliCommandGroupBuilder

Namespace
ItTiger.TigerCli.Commands
Assembly
ItTiger.TigerCli.dll
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

key string
provider Func<TigerCliProviderContext, Task<IReadOnlyList<string>>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

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

key string
provider Func<TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

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

key string
provider Func<TSettings, TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

Type Parameters

TSettings
TValue

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

name string
configure Action<TigerCliCommandGroupBuilder>

Returns

TigerCliCommandGroupBuilder

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

name string
configure Action<TigerCliCommandBuilder>
description string
descriptionResourceKey string

Returns

TigerCliCommandGroupBuilder

Type Parameters

TCommand

Exceptions

ArgumentException
name is 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

name string
factory Func<TCommand>
configure Action<TigerCliCommandBuilder>
description string
descriptionResourceKey string

Returns

TigerCliCommandGroupBuilder

Type Parameters

TCommand

Exceptions

ArgumentException
name is 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

name string
factory Func<TCommand>
description string
descriptionResourceKey string

Returns

TigerCliCommandGroupBuilder

Type Parameters

TCommand

Exceptions

ArgumentException
name is 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

name string
description string
descriptionResourceKey string

Returns

TigerCliCommandGroupBuilder

Type Parameters

TCommand

Exceptions

ArgumentException
name is 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

name string
The environment variable name.
description string
The help description. TigerCli markup is supported.

Returns

TigerCliCommandGroupBuilder
This builder for chaining.

Exceptions

ArgumentException
name or description is null, empty, or whitespace, or name contains whitespace.
InvalidOperationException
name duplicates 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

key string
provider Func<TigerCliProviderContext, IReadOnlyList<string>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

Exceptions

ArgumentException
key is null, empty, or whitespace.
ArgumentNullException
provider is null.

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

key string
provider Func<TigerCliProviderContext, Task<IReadOnlyList<string>>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

Exceptions

ArgumentException
key is null, empty, or whitespace.
ArgumentNullException
provider is null.

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

key string
provider Func<TigerCliProviderContext, IReadOnlyList<OptionItem<TValue>>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

Type Parameters

TValue

Exceptions

ArgumentException
key is null, empty, or whitespace.
ArgumentNullException
provider is null.

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

key string
provider Func<TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

Type Parameters

TValue

Exceptions

ArgumentException
key is null, empty, or whitespace.
ArgumentNullException
provider is null.

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

key string
provider Func<TSettings, TigerCliProviderContext, IReadOnlyList<OptionItem<TValue>>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

Type Parameters

TSettings
TValue

Exceptions

ArgumentException
key is null, empty, or whitespace.
ArgumentNullException
provider is null.

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

key string
provider Func<TSettings, TigerCliProviderContext, Task<IReadOnlyList<OptionItem<TValue>>>>
dependsOn IEnumerable<string>
configure Action<TigerCliProviderOptions>

Returns

TigerCliCommandGroupBuilder

Type Parameters

TSettings
TValue

Exceptions

ArgumentException
key is null, empty, or whitespace.
ArgumentNullException
provider is null.

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

mode CommandMenuMode

Returns

TigerCliCommandGroupBuilder

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

description string
Fallback description used when no resource key is provided or when the key fails to resolve.
resourceKey string
Optional resource key resolved through the app ResourceManager registered via UseAppResources against the active run culture. Missing keys silently fall back to description.

Returns

TigerCliCommandGroupBuilder

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

mode TigerCliPromptMode

Returns

TigerCliCommandGroupBuilder