/* Command Line ARGS: * -d --directory the directory where the source code will be * -f --file the (zip) file containing the source code (when this is set -d will be the extraction folder) * -b --build cmake | custom cmake will walk the (first) CMakeLists.txt * ^^^^^^^^^^ will only implement cmake * -h --help will call your mom */ static void Main(string[] args) //ARGS ARE: { CmdParser.Init(); if (!CmdParser.ParseArgs(args)) { return; } FileInteraction.FileInteraction.DoMutate(); }
public void TestInvalidKey() { CmdParser cmdParser = this.SpawnParser(); string[] args = new string[] { "/t1=\"in 1\"", "/t2", "/t3=input3" }; bool result = cmdParser.ParseArgs(args); Assert.IsTrue(result, "Valid argument parsing should return true for ParseArgs"); string falseValue = cmdParser.GetArg("i_do_not_exist"); }
public void TestValidCommandLineArguments() { CmdParser cmdParser = this.SpawnParser(); string[] args = new string[] { "/t1=\"in 1\"", "/t2", "/t3=input3" }; bool result = cmdParser.ParseArgs(args); Assert.IsTrue(result, "Valid argument parsing should return true for ParseArgs"); Assert.AreEqual <string>("\"in 1\"", cmdParser.GetArg("t1"), "Correct argument should match by key and be return as quoted if entered as such"); Assert.AreEqual <string>("", cmdParser.GetArg("t2"), "Argument value without input should simply be an empty string"); Assert.AreEqual <string>("input3", cmdParser.GetArg("t3"), "Correct argument should match by key and be returned without quotes if none were provided"); }
public void TestInvalidCommandLineArguments() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); CmdParser cmdParser = this.SpawnParser(); string[] args = new string[] { "t1=\"in 1\"", "/t2", "/t3=\"in 3\"" }; bool result = cmdParser.ParseArgs(args); Assert.IsFalse(result, "Invalid argument should return false on ParseArgs"); cmdParser.PrintErrors(); string expected = string.Format(" Invalid command line argument: t1=\"in 1\"{0}", Environment.NewLine); Assert.AreEqual <string>(expected, sw.ToString(), " Invalid command line argument: t1=\"in 1\""); } }
public void TestMissingCommandLineArguments() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); CmdParser cmdParser = this.SpawnParser(); string[] args = new string[] { "/t1=\"in 1\"", "/t2", }; bool result = cmdParser.ParseArgs(args); Assert.IsFalse(result, "Missing argument should return false on ParseArgs"); cmdParser.PrintErrors(); string expected = string.Format(" Missing command line argument: t3{0}", Environment.NewLine); Assert.AreEqual <string>(expected, sw.ToString(), "Missing arguments should provide accurate message"); } }