diff --git a/src/Dotty.CLI/Commands/ConvertCommands.cs b/src/Dotty.CLI/Commands/ConvertCommands.cs index c477b51..3545ca5 100644 --- a/src/Dotty.CLI/Commands/ConvertCommands.cs +++ b/src/Dotty.CLI/Commands/ConvertCommands.cs @@ -10,10 +10,14 @@ public void Register(ICoconaAppBuilder app) { app.AddSubCommand("convert", group => { - group.AddCommand("units", ConvertUnits); - group.AddCommand("tobase64", ([Argument] string input) => Panel(Convert.ToBase64String(Encoding.UTF8.GetBytes(input)))); - group.AddCommand("frombase64", ([Argument] string input) => Panel(Encoding.UTF8.GetString(Convert.FromBase64String(input)))); - }); + group.AddCommand("units", ConvertUnits) + .WithDescription("Converts a value from one unit of measurement to another"); + group.AddCommand("tobase64", ([Argument] string input) => Panel(Convert.ToBase64String(Encoding.UTF8.GetBytes(input)))) + .WithDescription("Converts a string to a base64 encoded string"); + group.AddCommand("frombase64", ([Argument] string input) => Panel(Encoding.UTF8.GetString(Convert.FromBase64String(input)))) + .WithDescription("Converts a base64 encoded string to a regular string"); + }) + .WithDescription("Contains commands to convert values"); } diff --git a/src/Dotty.CLI/Commands/GenerateCommands.cs b/src/Dotty.CLI/Commands/GenerateCommands.cs index 8d568cd..5f8d65d 100644 --- a/src/Dotty.CLI/Commands/GenerateCommands.cs +++ b/src/Dotty.CLI/Commands/GenerateCommands.cs @@ -7,23 +7,27 @@ public class GenerateCommands : ICommandDefinition public void Register(ICoconaAppBuilder app) { app.AddSubCommand("generate", group => - { - group.AddSubCommand("random", subgroup => { - subgroup.AddCommand("guid", () => Panel(Guid.NewGuid().ToString())); - - subgroup.AddCommand("number", ([Option('m')] int min = 0, [Option('M')] int max = 100) - => Panel(Random.Shared.Next(min, max).ToString())); + group.AddSubCommand("random", subgroup => + { + subgroup.AddCommand("guid", () => Panel(Guid.NewGuid().ToString())) + .WithDescription("Generates a random GUID"); - subgroup - .AddCommand("fromtemplate", ([Argument] string template) => Panel(new Faker().Parse(template))) - .WithDescription(""" - Can generate random data from a template using the Bogus library. - For example, `generate random fromtemplate '{{name.firstName(Male)}} {{name.lastName}}'` - """); - }); + subgroup.AddCommand("number", ([Option('m')] int min = 0, [Option('M')] int max = 100) + => Panel(Random.Shared.Next(min, max).ToString())) + .WithDescription("Generates a random number within a range"); - group.AddCommand("timestamp", (string format = "o") => Panel(DateTimeOffset.UtcNow.ToString(format))); - }); + subgroup + .AddCommand("fromtemplate", ([Argument] string template) => Panel(new Faker().Parse(template))) + .WithDescription(""" + Can generate random data from a template using the Bogus library. + For example, `generate random fromtemplate '{{name.firstName(Male)}} {{name.lastName}}'` + """); + }); + + group.AddCommand("timestamp", (string format = "o") => Panel(DateTimeOffset.UtcNow.ToString(format))) + .WithDescription("Generates a timestamp for the current datetime with an optional format string"); + }) + .WithDescription("Contains commands to generate certain data"); } } \ No newline at end of file diff --git a/src/Dotty.CLI/Commands/IntroduceCommand.cs b/src/Dotty.CLI/Commands/IntroduceCommand.cs index ea0c05e..674de9b 100644 --- a/src/Dotty.CLI/Commands/IntroduceCommand.cs +++ b/src/Dotty.CLI/Commands/IntroduceCommand.cs @@ -6,18 +6,24 @@ public void Register(ICoconaAppBuilder app) { app.AddSubCommand("introduce", group => { - group.AddCommand("talk", () => Panel("Welcome to this talk on crafting modern CLI tools using .NET")); - group.AddCommand("speaker", IntroduceSpeaker); + group.AddCommand("talk", () => Panel("Welcome to this talk on crafting modern CLI tools using .NET")) + .WithDescription("Introduces the talk"); + + group.AddCommand("speaker", IntroduceSpeaker) + .WithDescription("Introduces the speaker"); + group.AddCommand("yourself", () => - { - Panel(""" - Hi, I'm Dotty, a CLI tool written in C# with dotnet. - I'm an assistant here to help you with various tasks! - - PS: My name is a play on words: Dotnet + Clippy. Remember Clippy? - """); - }); - }); + { + Panel(""" + Hi, I'm Dotty, a CLI tool written in C# with dotnet. + I'm an assistant here to help you with various tasks! + + PS: My name is a play on words: Dotnet + Clippy. Remember Clippy? + """); + }) + .WithDescription("Introduces Dotty"); + }) + .WithDescription("Contains commands to introduce various elements"); } private static void IntroduceSpeaker([Option('n')] string? name = null) diff --git a/src/Dotty.CLI/Commands/PresentCommands.cs b/src/Dotty.CLI/Commands/PresentCommands.cs index 4f43a9d..4e7f5b0 100644 --- a/src/Dotty.CLI/Commands/PresentCommands.cs +++ b/src/Dotty.CLI/Commands/PresentCommands.cs @@ -16,6 +16,7 @@ public void Register(ICoconaAppBuilder app) UseShellExecute = true }); }); - }); + }) + .WithDescription("Opens the presentation slides for the talk"); } } \ No newline at end of file diff --git a/src/Dotty.CLI/Commands/SimpleCommands.cs b/src/Dotty.CLI/Commands/SimpleCommands.cs index dd47cff..0758da4 100644 --- a/src/Dotty.CLI/Commands/SimpleCommands.cs +++ b/src/Dotty.CLI/Commands/SimpleCommands.cs @@ -8,7 +8,8 @@ public class SimpleCommands : ICommandDefinition { public void Register(ICoconaAppBuilder app) { - app.AddCommand("greet", ([Argument] string subject) => Panel($"Hello, {subject}!")); + app.AddCommand("greet", ([Argument] string subject) => Panel($"Hello, {subject}!")) + .WithDescription("Greets any subject"); app.AddCommand(([FromService] ICoconaApplicationMetadataProvider metadataProvider, [FromService] ICoconaHelpMessageBuilder helpProvider) => { diff --git a/src/Dotty.CLI/Commands/WeatherCommands.cs b/src/Dotty.CLI/Commands/WeatherCommands.cs index ebfb162..8b27d9b 100644 --- a/src/Dotty.CLI/Commands/WeatherCommands.cs +++ b/src/Dotty.CLI/Commands/WeatherCommands.cs @@ -9,7 +9,8 @@ public class WeatherCommands : ICommandDefinition { public void Register(ICoconaAppBuilder app) { - app.AddCommand("weather", ExecuteWeatherCommand); + app.AddCommand("weather", ExecuteWeatherCommand) + .WithDescription("Gets the weather for a specific city"); } private static async Task ExecuteWeatherCommand([FromService] IWeatherService weatherService, [Argument] string city)