-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppConfiguration.cs
More file actions
85 lines (80 loc) · 3.65 KB
/
AppConfiguration.cs
File metadata and controls
85 lines (80 loc) · 3.65 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System.Reflection;
using BuslyCLI.Commands.Demo;
using BuslyCLI.Commands.NsbCommand;
using BuslyCLI.Commands.NsbEvent;
using BuslyCLI.Commands.NsbTimeout;
using BuslyCLI.Commands.Transport;
using Spectre.Console;
using Spectre.Console.Cli;
namespace BuslyCLI.Infrastructure;
public static class AppConfiguration
{
public static Action<IConfigurator> GetSpectreCommandConfiguration()
{
return config =>
{
config.SetApplicationName("busly");
// TODO: Allow this to get set via the CLI version
var assembly = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>();
config.SetApplicationVersion(assembly.InformationalVersion);
config.AddBranch("transport", transport =>
{
transport.SetDescription("Manage transport configurations.");
transport.AddCommand<ListTransportsCommand>("list")
.WithAlias("ls")
.WithDescription("List all configured transports.");
transport.AddCommand<CurrentTransportCommand>("current")
.WithAlias("c")
.WithDescription("Display current transport.");
transport.AddCommand<DeleteTransportCommand>("delete")
.WithAlias("d")
.WithDescription("Delete a configured transport.");
transport.AddCommand<SetTransportCommand>("set")
.WithAlias("s")
.WithDescription("Set the current transport.");
});
config.AddBranch("command", command =>
{
command.SetDescription("Operations related to NServiceBus commands.");
command.AddCommand<SendCommand>("send")
.WithAlias("s")
.WithDescription("Send a one-way command to an endpoint.");
});
config.AddBranch("event", @event =>
{
@event.SetDescription("Operations related to NServiceBus events.");
@event.AddCommand<PublishCommand>("publish")
.WithAlias("p")
.WithDescription("Publish an event to subscribing endpoints.");
});
config.AddBranch("timeout", timeout =>
{
timeout.SetDescription("Operations related to NServiceBus timeouts.");
timeout.AddCommand<SendTimeout>("send")
.WithAlias("s")
.WithDescription("Send a timeout message to an endpoint.");
});
config.AddBranch("demo", demo =>
{
demo.SetDescription("Demo mode for the busly quick start guide.");
demo.AddCommand<StartDemoCommand>("start")
.WithDescription("Start a demo endpoint that can receive any command and a single 'Messages.Events.OrderPlaced' event.");
});
config.SetExceptionHandler((ex, _) =>
{
// if (ex.InnerException is OptionsValidationException)
// {
// AnsiConsole.Write(new Markup($"{ConsoleExtensions.ErrorMarkup}{ex.InnerException.Message}"));
// return;
// }
// if (ex is CommandAppException)
// {
// AnsiConsole.Write(new Markup($"{ConsoleExtensions.ErrorMarkup}{ex.Message}"));
// return;
// }
// AnsiConsole.WriteException(ex, ExceptionFormats.ShortenPaths);
AnsiConsole.WriteException(ex, ExceptionFormats.ShortenEverything);
});
};
}
}