-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCreateRandomAnimalCommand.cs
More file actions
43 lines (37 loc) · 1.07 KB
/
CreateRandomAnimalCommand.cs
File metadata and controls
43 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Threading.Tasks;
using TreeBasedCli;
namespace Samples.AnimalKingdom
{
public class CreateRandomAnimalCommand :
LeafCommand<CreateRandomAnimalCommand.Handler>
{
public CreateRandomAnimalCommand() : base(
label: "create-random-animal",
description: new[]
{
"Prints out a random animal."
})
{ }
public class Handler : ILeafCommandHandler
{
private readonly IUserInterface userInterface;
public Handler(IUserInterface userInterface)
{
this.userInterface = userInterface;
}
public Task HandleAsync(LeafCommand _)
{
var animals = new[]
{
"🦔",
"🐝",
"🐘"
};
string animal = animals[Random.Shared.Next(0, 3)];
this.userInterface.WriteLine(animal);
return Task.CompletedTask;
}
}
}
}