public static RootCommand CreateCommand() { return(new RootCommand("A simple tool to manage DLCs.\r\nTHIS IS EXPERIMENTAL, USE AT YOUR OWN RISKS!") { new Option <bool>("-mainnet", "Use mainnet (default)") { IsRequired = false }, new Option <bool>("-testnet", "Use testnet") { IsRequired = false }, new Option <bool>("-regtest", "Use regtest") { IsRequired = false }, new Option <string>("--datadir", "The data directory") { IsRequired = false }, ShowInfoCommand.CreateCommand(), new Command("oracle", "Oracle commands") { AddSetOracleCommand.CreateCommand(false), AddSetOracleCommand.CreateCommand(true), RemoveOracleCommand.CreateCommand(), ListOracleCommand.CreateCommand(), ShowOracleCommand.CreateCommand(), GenerateOracleCommand.CreateCommand() }, new Command("event", "Manage events") { AddEventCommand.CreateCommand(), ListEventsCommand.CreateCommand(), ShowEventCommand.CreateCommand(), GenerateEventCommand.CreateCommand(), new Command("attest", "Attest an event") { AttestAddCommand.CreateCommand(), AttestSignCommand.CreateCommand() } }, new Command("dlc", "Manage DLCs") { OfferDLCCommand.CreateCommand(), SetupDLCCommand.CreateCommand(), ReviewDLCCommand.CreateCommand(), AcceptDLCCommand.CreateCommand(), CheckSignatureDLCCommand.CreateCommand(), StartDLCCommand.CreateCommand(), ExecuteDLCCommand.CreateCommand(), ExtractDLCCommand.CreateCommand(), ShowDLCCommand.CreateCommand(), ListDLCCommand.CreateCommand() } }); }
public string DispatchCommand(string[] commandParameters) { string commandName = commandParameters[0]; commandParameters = commandParameters.Skip(1).ToArray(); string result = string.Empty; EventService eventService = new EventService(); switch (commandName) { case "CreateEvent": CreateEventCommand createEvent = new CreateEventCommand(eventService); result = createEvent.Execute(commandParameters); break; case "DeleteEvent": DeleteEventCommand deleteEvent = new DeleteEventCommand(eventService); result = deleteEvent.Execute(commandParameters); break; case "EditEvent": EditEventCommand editEvent = new EditEventCommand(eventService); result = editEvent.Execute(commandParameters); break; case "ListEvents": ListEventsCommand listEvents = new ListEventsCommand(eventService); result = listEvents.Execute(commandParameters); break; case "Help": HelpCommand help = new HelpCommand(); result = help.Execute(commandParameters); break; case "Exit": ExitCommand exit = new ExitCommand(eventService); result = exit.Execute(commandParameters); break; default: result = $@"Command {commandName} does not exist. Type ""Help"" to check the available commands."; break; } return(result); }