static void Main(string[] args) { /*OptionParser parser = new OptionParser(new OptionParser.Configuration * { * AllowArgumentsBetweenOptions = true, * OptionDefinitions = new Option[] * { * new Option("h", "help", "Help", "Shows help", false, false), * new Option("o", "output", "Output", "Show output", false), * new Option("e", "extract", "Extract", "Extracts a file", true) * } * }); * * var result = parser.ParseAll("-h 'argumento lol' -e hola").ToList();*/ var margs = ArgumentStructure.Parse <MyArgs>("-h argumento lol"); if (margs.ShowHelp) { Console.WriteLine(ArgumentStructure.GetCommandUsage <MyArgs>()); } //var res = Lexer.Parse("-e lol xd --hola").ToList(); Console.WriteLine("Done"); Console.ReadLine(); }
public void ReflectionArrayImplicitOptions() { string[] testArray = "--testString 'hola' --testBool".Split(' '); TestClass2 parsed = ArgumentStructure.Parse <TestClass2>(testArray); Assert.AreEqual("hola", parsed.TestString); Assert.IsTrue(parsed.TestBool); }
public void ReflectionStringImplicitOptions() { string testString = "--testString 'hola' --testBool"; TestClass2 parsed = ArgumentStructure.Parse <TestClass2>(testString); Assert.AreEqual("hola", parsed.TestString); Assert.IsTrue(parsed.TestBool); }
public void ReflectionArrayExplicitOptions() { string[] testArray = "--testString 'hola' --testBool".Split(' '); TestClass1 parsed = ArgumentStructure.Parse <TestClass1>(testArray, new Option[] { new Option("a", "testString", "testString", "hoijo", true), new Option("b", "testBool", "testBool", "edhroirtjho") }); Assert.AreEqual("hola", parsed.TestString); Assert.IsTrue(parsed.TestBool); }
public void DictionaryArray() { string[] testArray = "--testString 'hola' --testBool".Split(' '); var options = new Option[] { new Option("a", "testString", "testString", "hoijo", true), new Option("b", "testBool", "testBool", "edhroirtjho") }; var parsed = ArgumentStructure.Parse(testArray, options); //Assert.AreEqual("hola", parsed[options[0]]); //Assert.IsTrue(parsed.ContainsKey(options[1])); }
public void CommandWithArguments() { var result = ArgumentStructure.Parse <TestClass2>("argument1 'argument 2'"); string[] expected = new[] { "argument1", "argument 2" }; bool areEqual = true; for (int i = 0; i < expected.Length; i++) { if (result.Arguments[i] != expected[i]) { areEqual = false; } } Assert.IsTrue(areEqual); }
public void ArgumentStructureWithoutOptionDefinitionsShouldThrow() { Assert.ThrowsException <ArgumentException>(() => ArgumentStructure.Parse <TestClass4>("")); }