public void Run(CommandLine commandLine) { var config = this.LoadConfig(commandLine.SitePath, commandLine.OutputPath); var lastRunState = this.LoadLastRunState(commandLine.SitePath); switch (commandLine.Command) { case ProcessingCommand.Render: { var engines = RenderingEngine.Load(); var command = new RunRenderCommand(config, lastRunState, engines); lastRunState = command.Execute(); } break; case ProcessingCommand.Serve: { var command = new RunServeCommand(config, commandLine.Port); command.Execute(); } break; case ProcessingCommand.Watch: { var engines = RenderingEngine.Load(); var command = new RunWatchCommand(config, commandLine.Port, lastRunState, engines); command.Execute(); } break; default: throw new InvalidOperationException($"Unknown ProcessingCommand: {commandLine.Command}"); } this.SaveLastRunState(commandLine.SitePath, lastRunState); }
public async Task Run(CommandLine commandLine) { var config = await this.LoadConfig(commandLine.SitePath, commandLine.OutputPath); var lastRunState = await this.LoadLastRunState(commandLine.SitePath); switch (commandLine.Command) { case ProcessingCommand.Render: { var engines = RenderingEngine.Load(); var command = new RunRenderCommand(config, lastRunState, engines); await command.ExecuteAsync(); lastRunState = command.LastRunState; } break; case ProcessingCommand.Serve: { var command = new RunServeCommand(); command.Config = config; command.Execute(); } break; case ProcessingCommand.Watch: { var engines = RenderingEngine.Load(); var command = new RunWatchCommand(config, lastRunState, engines); command.Execute(); } break; default: throw new InvalidOperationException(String.Format("Unknown ProcessingCommand: {0}", commandLine.Command)); } await this.SaveLastRunState(commandLine.SitePath, lastRunState); }