private static int RunCmd(ExecuteCommandOptions opts) { if (!string.IsNullOrWhiteSpace(opts.File)) { if (!File.Exists(opts.File)) { Console.WriteLine($"Could not find file '{opts.File}'"); return(-55); } var content = File.ReadAllText(opts.File); if (string.IsNullOrWhiteSpace(content)) { Console.WriteLine($"File is empty ('{opts.File}')"); return(-56); } try { var d = new Deserializer(); opts.Script = d.Deserialize <RdmpScript>(content); } catch (Exception ex) { Console.WriteLine($"Error deserializing '{opts.File}': {ex.Message}"); return(-57); } } return(Run((RDMPCommandLineOptions)opts)); }
/// <summary> /// Runs the provided string which should start after the cmd e.g. the bit after rdmp cmd /// </summary> /// <param name="command">1 string per piece following rdmp cmd. Element 0 should be the Type of command to run</param> /// <returns></returns> protected int Run(params string[] command) { var opts = new ExecuteCommandOptions(); opts.CommandName = command[0]; opts.CommandArgs = command.Skip(1).ToArray(); var runner = new ExecuteCommandRunner(opts); return(runner.Run(RepositoryLocator, new ThrowImmediatelyDataLoadEventListener(), new ThrowImmediatelyCheckNotifier(), new GracefulCancellationToken())); }
public void SimpleTest(string expected) { var model = new ExecuteCommandOptions { Commands = new[] { "command1", "command2" } }; var result = Fixture.SerializeObject(model); result.Should().Be(expected); var deresult = new Serializer(ClientVersion.Lsp3).DeserializeObject <ExecuteCommandOptions>(expected); deresult.Should().BeEquivalentTo(model); }
public void SimpleTest(string expected) { var model = new ExecuteCommandOptions() { Commands = new string[] { "command1", "command2" } }; var result = Fixture.SerializeObject(model); result.Should().Be(expected); var deresult = JsonConvert.DeserializeObject <ExecuteCommandOptions>(expected); deresult.ShouldBeEquivalentTo(model); }
public ExecuteCommandRunner(ExecuteCommandOptions options) { _options = options; }