Skip to content

Commit

Permalink
Fix names on generate random number command
Browse files Browse the repository at this point in the history
  • Loading branch information
DanteDeRuwe committed Nov 19, 2024
1 parent 30aba97 commit 2a0c8da
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/Dotty.CLI/Commands/GenerateCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@ public void Register(ICoconaAppBuilder app)
app.AddSubCommand("generate", group =>
{
group.AddSubCommand("random", subgroup =>
{
subgroup.AddCommand("guid", () => Panel(Guid.NewGuid().ToString()))
.WithDescription("Generates a random GUID");
{
subgroup.AddCommand("guid", () => Panel(Guid.NewGuid().ToString()))
.WithDescription("Generates a random GUID");

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");
subgroup.AddCommand("number", ([Option('f')] int from = 0, [Option('t')] int to = 100) =>
{
if (from >= to)
{
Console.WriteLine("Error: The 'from' value cannot be greater than the 'to' value");
return 1;
}

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}}'`
""");
})
.WithDescription("Contains commands to generate certain random data");
var number = Random.Shared.Next(from, to);
Panel($"Generated number: {number}");
return 0;
})
.WithDescription("Generates a random number within a range");

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}}'`
""");
})
.WithDescription("Contains commands to generate certain random data");

group.AddCommand("timestamp", (string format = "o") => Panel(DateTimeOffset.UtcNow.ToString(format)))
.WithDescription("Generates a timestamp for the current datetime with an optional format string");
Expand Down

0 comments on commit 2a0c8da

Please sign in to comment.