static void Main(string[] args) { var options = new CliOptions(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { var data = Enumerable.Range(1, 10) .Select(UserWithId) .Cast <object>() .ToList(); var container = SetupContainer.Build( new InMemoryDataStore(data)); // Get to work. var router = new RouteCommand(container); Execute(options, router); container.Dispose(); } }
static void Execute(CliOptions options, IRouteCommand router) { if (options.UserToCreate != null && !options.Admin) { router.Route( new CreateUserCommand { Username = options.UserToCreate }); } if (options.UserToCreate != null && options.Admin) { if (options.Admin) { router.Route( new CreateAdminUserCommand { Username = options.UserToCreate }); } } if (options.UserToPromote != null) { router.Route( new PromoteUserCommand { Username = options.UserToPromote }); } if (options.UserToDelete != null) { router.Route( new DeleteUserCommand { Username = options.UserToDelete }); } }