Class TigerCliCommandBuilder
Configures metadata, providers, and help-only environment-variable registrations for a single
command registration.
public sealed class TigerCliCommandBuilder
- Inheritance
-
TigerCliCommandBuilder
- Inherited Members
Methods
AddAsyncProvider(string, Func<TigerCliProviderContext, Task<IReadOnlyList<string>>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers an async command-level string provider. 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 TigerCliCommandBuilder 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 command-level named provider. 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 TigerCliCommandBuilder 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 command-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 TigerCliCommandBuilder 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
AddEnvironmentVariable(string, string)
Adds command-local help metadata for an environment variable recognized by the command.
TigerCli displays it in this command's
--help-env output; it does not read, parse, or
apply the variable.public TigerCliCommandBuilder AddEnvironmentVariable(string name, string description)
Parameters
namestring- The environment variable name.
descriptionstring- The help description. TigerCli markup is supported.
Returns
- TigerCliCommandBuilder
- This builder for chaining.
Exceptions
- ArgumentException
nameordescriptionis null, empty, or whitespace, ornamecontains whitespace.- InvalidOperationException
nameduplicates another variable on this command.
AddProvider(string, Func<TigerCliProviderContext, IReadOnlyList<string>>, IEnumerable<string>?, Action<TigerCliProviderOptions>?)
Registers a sync command-level string provider; each returned string is used as both value
and label. Prefer the async overloads for slow or I/O-backed providers.
public TigerCliCommandBuilder 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 command-level string provider; 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 TigerCliCommandBuilder 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 command-level named provider returning key/label pairs
(OptionItem<TKey>). Prefer the async overloads for slow or I/O-backed
providers.
public TigerCliCommandBuilder 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 command-level named provider returning key/label pairs
(OptionItem<TKey>). Equivalent to the
AddAsyncProvider spelling,
which is preferred for new code.public TigerCliCommandBuilder 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 command-level named provider that additionally receives the partially
bound settings instance. Prefer the async overloads for slow or I/O-backed providers.
public TigerCliCommandBuilder 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 command-level named provider that additionally receives the partially
bound settings instance, letting the choices depend on values supplied earlier in the run.
Equivalent to the
AddAsyncProvider spelling, which is preferred for new code.public TigerCliCommandBuilder 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.
AppendTitle(string)
Appends command-specific text to the app title for this command, using
{AppTitle} - {titleAppend}. Cannot be combined with SetTitle(string).public TigerCliCommandBuilder AppendTitle(string titleAppend)
Parameters
titleAppendstring
Returns
Exceptions
- ArgumentException
titleAppendis null, empty, or whitespace.- InvalidOperationException
- SetTitle(string) was already configured.
AsEdit<TSettings>(Func<TSettings, TigerCliEditLoad<TSettings>>)
Synchronous overload of
AsEdit<TSettings>(Func<TSettings, Task<TigerCliEditLoad<TSettings>>>).
public TigerCliCommandBuilder AsEdit<TSettings>(Func<TSettings, TigerCliEditLoad<TSettings>> loader) where TSettings : TigerCliSettings
Parameters
loaderFunc<TSettings, TigerCliEditLoad<TSettings>>
Returns
Type Parameters
TSettings
AsEdit<TSettings>(Func<TSettings, Task<TigerCliEditLoad<TSettings>>>)
Marks this command as an edit command. Before prompting, the framework invokes
loader with the already-bound settings (selector arguments and
command-line overrides applied). The loader returns
Found(TSettings) with the existing object's values,
or NotFound(). Existing values seed every
property that was not supplied on the command line; command-line values always win.
The command handler still owns saving the edited object.public TigerCliCommandBuilder AsEdit<TSettings>(Func<TSettings, Task<TigerCliEditLoad<TSettings>>> loader) where TSettings : TigerCliSettings
Parameters
loaderFunc<TSettings, Task<TigerCliEditLoad<TSettings>>>
Returns
Type Parameters
TSettings
CommandMenu(CommandMenuMode)
Sets this command's command-menu opinion. Combined with the app and group levels, a command
is shown in the menu when the chain has at least one Enabled
and no Disabled. Use Disabled to
hide an otherwise-eligible command from the menu.
public TigerCliCommandBuilder CommandMenu(CommandMenuMode mode)
Parameters
modeCommandMenuMode
Returns
SetPromptMode(TigerCliPromptMode)
Sets the prompt mode override for this command registration.
public TigerCliCommandBuilder SetPromptMode(TigerCliPromptMode mode)
Parameters
modeTigerCliPromptMode
Returns
SetTitle(string)
Replaces the app title entirely while this command is active. Cannot be combined with
AppendTitle(string).
public TigerCliCommandBuilder SetTitle(string titleSet)
Parameters
titleSetstring
Returns
Exceptions
- ArgumentException
titleSetis null, empty, or whitespace.- InvalidOperationException
- AppendTitle(string) was already configured.