-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to set description and/or data for the default command (
- Loading branch information
Showing
6 changed files
with
151 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Spectre.Console.Cli/Internal/Configuration/DefaultCommandConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace Spectre.Console.Cli.Internal.Configuration; | ||
|
||
/// <summary> | ||
/// Fluent configurator for the default command. | ||
/// </summary> | ||
public sealed class DefaultCommandConfigurator | ||
{ | ||
private readonly ConfiguredCommand _defaultCommand; | ||
|
||
internal DefaultCommandConfigurator(ConfiguredCommand defaultCommand) | ||
{ | ||
_defaultCommand = defaultCommand; | ||
} | ||
|
||
/// <summary> | ||
/// Sets the description of the default command. | ||
/// </summary> | ||
/// <param name="description">The default command description.</param> | ||
/// <returns>The same <see cref="DefaultCommandConfigurator"/> instance so that multiple calls can be chained.</returns> | ||
public DefaultCommandConfigurator WithDescription(string description) | ||
{ | ||
_defaultCommand.Description = description; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Sets data that will be passed to the command via the <see cref="CommandContext"/>. | ||
/// </summary> | ||
/// <param name="data">The data to pass to the default command.</param> | ||
/// <returns>The same <see cref="DefaultCommandConfigurator"/> instance so that multiple calls can be chained.</returns> | ||
public DefaultCommandConfigurator WithData(object data) | ||
{ | ||
_defaultCommand.Data = data; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters