public void ParseCmdLineAssignmentOpTest()
        {
            var parser = new CmdLineParser <TestCmdLineObj>();
            var args   = new string[]
            {
                "/Name=Billy Bob",
                "/Age=25",
                "/Occupation=Stranger",
                "/HasHair=false",
                "/Children=Billy,Bob,Betty",
                "/PersonType=Father"
            };

            parser.Options.AssignmentDelimiter = "=";
            // Need to set ArraySeparator as well.
            Assert.That.Throws <InvalidOperationException>(() => { parser.Parse(args); });

            parser.Options.ArraySeparator = ",";
            var results = parser.Parse(args);
            var obj     = results.Args;

            Assert.IsNotNull(obj);
            Assert.AreEqual("Billy Bob", obj.Name);
            Assert.AreEqual(25, obj.Age);
            Assert.AreEqual("Stranger", obj.Occupation);
            Assert.AreEqual(false, obj.HasHair);
            Assert.AreEqual(3, obj.Children.Length);
            Assert.AreEqual("Billy", obj.Children[0]);
            Assert.AreEqual("Bob", obj.Children[1]);
            Assert.AreEqual("Betty", obj.Children[2]);
            Assert.AreEqual(PersonType.Father, obj.PersonType);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the Options class with the specified command
        /// line arguments.
        /// </summary>
        /// <param name="args">The arguments passed on the command line.</param>
        public Options(string[] args)
        {
            // Initialize the options
            _StartDateOption = new DateOption("s", "startdate");
            _BuildOption     = new StringOption("b", "build", "Fixed");
            _PinOption       = new StringOption("p", "pin", "0.0.0.0");
            _RevisionOption  = new StringOption("r", "revision", "Automatic");
            _InputFile       = new StringOption("i", "inputfile");
            _OutputFile      = new StringOption("o", "outputfile");
            _Input           = new StringOption("in", "input");
            _VersionOption   = new StringOption("v", "version");

            // Create a new command line parser and add our options
            CmdLineParser parser = new CmdLineParser();

            parser.AddOption(_StartDateOption);
            parser.AddOption(_BuildOption);
            parser.AddOption(_PinOption);
            parser.AddOption(_RevisionOption);
            parser.AddOption(_InputFile);
            parser.AddOption(_OutputFile);
            parser.AddOption(_VersionOption);

            // Try to parse our options
            try
            {
                parser.Parse(args);
                ValidatePinOption();
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void ParseCmdLineWithAliasTest()
        {
            var parser = new CmdLineParser <TestCmdLineObj>();
            var args   = new string[]
            {
                "/Name", "Billy Bob",
                "/Age", "25",
                "/Job", "Stranger",
                "/HasHair", "false",
                "/Children", "Billy", "Bob", "Betty"
            };

            var results = parser.Parse(args);
            var obj     = results.Args;

            Assert.IsNotNull(obj);
            Assert.AreEqual("Billy Bob", obj.Name);
            Assert.AreEqual(25, obj.Age);
            Assert.AreEqual("Stranger", obj.Occupation);
            Assert.AreEqual(false, obj.HasHair);
            Assert.AreEqual(3, obj.Children.Length);
            Assert.AreEqual("Billy", obj.Children[0]);
            Assert.AreEqual("Bob", obj.Children[1]);
            Assert.AreEqual("Betty", obj.Children[2]);
        }
        public void ParseCmdLineWithArrayTest()
        {
            var parser = new CmdLineParser <TestCmdLineObj>();
            var args   = new string[]
            {
                "/Name", "Billy Bob",
                "/Age", "25",
                "/Occupation", "Stranger",
                "/HasHair", "false",
                "/Children", "Billy,Bob,Betty",
                "/PersonType", "Father"
            };

            parser.Options.ArraySeparator = ",";
            var results = parser.Parse(args);
            var obj     = results.Args;

            Assert.IsNotNull(obj);
            Assert.AreEqual("Billy Bob", obj.Name);
            Assert.AreEqual(25, obj.Age);
            Assert.AreEqual("Stranger", obj.Occupation);
            Assert.AreEqual(false, obj.HasHair);
            Assert.AreEqual(3, obj.Children.Length);
            Assert.AreEqual("Billy", obj.Children[0]);
            Assert.AreEqual("Bob", obj.Children[1]);
            Assert.AreEqual("Betty", obj.Children[2]);
            Assert.AreEqual(PersonType.Father, obj.PersonType);

            args = new string[]
            {
                "/Name", "Billy Bob",
                "/Age", "25",
                "/Occupation", "Stranger",
                "/HasHair", "false",
                "/Children", @"Billy\~Bob\~Betty",
                "/PersonType", "Father"
            };

            parser.Options.ArraySeparator = @"\~";             // Use a sequence that might effect the regex.
            results = parser.Parse(args);
            obj     = results.Args;
            Assert.IsNotNull(obj);
            Assert.AreEqual(3, obj.Children.Length);
            Assert.AreEqual("Billy", obj.Children[0]);
            Assert.AreEqual("Bob", obj.Children[1]);
            Assert.AreEqual("Betty", obj.Children[2]);
        }
 public void ShouldParseMissingOptionalArg()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Arg("name").IsOptional();
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     parser.Parse(new string[0]);
 }
 public void ShouldParseMultipleUndefinedOptionIfAllowed()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     var settings = new CmdLineSettings { UndefinedOptionsPolicy = UndefinedOptionsPolicy.AllowMultipleInstances };
     var parser = new CmdLineParser(builder.Definition, settings);
     var input = parser.Parse("-name:value1.1;value1.2", "-name:value2.1;value2.2");
     input.UndefinedOptions.GetAll("name").ShouldBe(new[] { new[] { "value1.1", "value1.2" }, new[] { "value2.1", "value2.2" } });
 }
 public void ShouldParseOptionsWithSeparatedFormat()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Option("name").Value("value");
     var settings = new CmdLineSettings { OptionValueFormat = OptionValueFormat.Separated };
     var parser = new CmdLineParser(builder.Definition, settings);
     var input = parser.Parse("-name", "foo");
     input.Options.GetSingle("name").GetSingle("value").ShouldBe("foo");
 }
 public void ShouldParseFlagOption()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Option("name");
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     var input = parser.Parse(new[] { "-name" });
     input.Options.Contains("name").ShouldBe(true);
 }
 public void ShouldParseArg()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Arg("name");
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     var input = parser.Parse(new[] { "value" });
     input.Args.GetSingle("name").ShouldBe("value");
 }
 public void ShouldParseOptionWithParamsValue()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Option("name")
            .Value("value", x => x.IsParams());
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     var input = parser.Parse("-name:foo;bar");
     input.Options.GetSingle("name").GetAll("value").ShouldBe(new[] { "foo", "bar" });
 }
Beispiel #11
0
        public void GenerateUsageTest()
        {
            var parser  = new CmdLineParser <TestCmdLineObj>();
            var results = parser.Parse(new string[] { });

            results.ApplicationFileName = "test.exe";
            var generator = new HelpGenerator(results);

            var usage = generator.GetUsage();

            Assert.AreEqual("test.exe <Name|String> [/Type <Father|Mother|Child>]", usage);
        }
        public void ParseStandardCmdLineTest()
        {
            var parser = new CmdLineParser <TestCmdLineObj>();
            var args   = new string[]
            {
                "/Name", "Billy Bob",
                "/Age", "25",
                "/Occupation", "Stranger",
                "/HasHair", "false",
                "/Children", "Billy", "Bob", "Betty",
                "/PersonType", "Father"
            };

            var results = parser.Parse(args);
            var obj     = results.Args;

            Assert.IsNotNull(obj);
            Assert.AreEqual("Billy Bob", obj.Name);
            Assert.AreEqual(25, obj.Age);
            Assert.AreEqual("Stranger", obj.Occupation);
            Assert.AreEqual(false, obj.HasHair);
            Assert.AreEqual(3, obj.Children.Length);
            Assert.AreEqual("Billy", obj.Children[0]);
            Assert.AreEqual("Bob", obj.Children[1]);
            Assert.AreEqual("Betty", obj.Children[2]);
            Assert.AreEqual(PersonType.Father, obj.PersonType);

            args = new string[]
            {
                "/HasHair-",                 // Use a negation flag.
            };

            results = parser.Parse(args);
            obj     = results.Args;
            Assert.IsNotNull(obj);
            Assert.AreEqual(false, obj.HasHair);
            Assert.IsTrue(results.Properties["HasHair"].ValueSet);
        }
 public void ShouldParseMultipleInstancesOfAllowMultipleOption()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Option("name")
            .AllowMultiple()
            .Value("value");
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     var input = parser.Parse("-name:foo", "-name:bar");
     var options = input.Options.GetAll("name");
     options.Length.ShouldBe(2);
     options[0].GetSingle("value").ShouldBe("foo");
     options[1].GetSingle("value").ShouldBe("bar");
 }
        public void ParseCmdLineIntValidationTest()
        {
            //https://github.com/BizArk/BizArk3/issues/7

            var parser = new CmdLineParser <TestCmdLineObj>();
            var args   = new string[]
            {
                "/Name", "Billy Bob"
            };

            var results = parser.Parse(args);

            Assert.AreEqual(1, results.Errors.Length);
            Assert.AreEqual("Age is required.", results.Errors[0]);
        }
        public void ParseCmdLineParseErrorTest()
        {
            var parser = new CmdLineParser <TestCmdLineObj>();
            var args   = new string[]
            {
                "/Age", "XXX",
                "/ChildrenAges", "1", "XXX", "3"
            };

            var results = parser.Parse(args);

            Assert.AreEqual(3, results.Errors.Length);
            Assert.AreEqual("Unable to set Age. Value <XXX> is not valid.", results.Errors[0]);
            Assert.AreEqual("Unable to set ChildrenAges. Invalid value.", results.Errors[1]);
            Assert.AreEqual("Name is required.", results.Errors[2]);
        }
        public void ParseCmdLineValidationTest()
        {
            var parser = new CmdLineParser <TestCmdLineObj>();
            var args   = new string[]
            {
                "/Age", "25",
                "/Job", "A really long invalid name",
                "/HasHair", "false",
                "/Children", "Billy", "Bob", "Betty"
            };

            var results = parser.Parse(args);

            Assert.AreEqual(2, results.Errors.Length);
            Assert.AreEqual("Name is required.", results.Errors[0]);
            Assert.AreEqual("Job name too long.", results.Errors[1]);
        }
Beispiel #17
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            if (e.Args.Length > 0)
            {
                try
                {
                    var parser = new CmdLineParser {
                        ThrowInvalidOptionsException = false
                    };

                    var pathArgument = parser.AddStringParameter("/path", "Directory", false);
                    pathArgument.AddAlias("pATH");
                    pathArgument.AddAlias("-path");
                    pathArgument.AddAlias("-dir");

                    var subDirs = parser.AddBoolSwitch("s", "Including subdirs");

                    var noWindow = parser.AddBoolSwitch("nowindow", "No window is shown");

                    parser.AddHelpOption();

                    //var boolArgument = parser.AddBoolSwitch("-TestBool", "", true);

                    parser.Parse(e.Args);

                    System.Diagnostics.Debug.WriteLine(pathArgument.Value);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);

                    //throw;
                }
            }
            else
            {
                new MainWindow().ShowDialog();
            }
            Shutdown();
        }
Beispiel #18
0
        public void GenerateExitCodesTest()
        {
            // No exit codes have been defined.
            var parser  = new CmdLineParser <TestCmdLineObj>();
            var results = parser.Parse(new string[] { });

            parser.Options.ExitCodes = null;
            var generator = new HelpGenerator(results);
            var help      = generator.GetExitCodesDisplay();

            Assert.AreEqual("", help);


            // Verify the parser can find the ExitCodes enum and InvalidArgs value.
            parser    = new CmdLineParser <TestCmdLineObj>();
            results   = parser.Parse(new string[] { });
            generator = new HelpGenerator(results);

            help = generator.GetExitCodesDisplay();
            Assert.AreEqual("   0 = Success!!!\r\n1234 = Failed :'(\r\n", help);
            Assert.AreEqual((int)ExitCodes.InvalidArgs, parser.Options.InvalidArgsExitCode);
            Assert.IsNull(parser.Options.FatalErrorExitCode);
        }
Beispiel #19
0
        public static void Main(string[] args)
        {
            InitializeDefaults();

            //Parse Command Line Arguments
            if (CmdLineParser.Parse(args))
            {
                Console.WriteLine(" --> Error parsing command line - quiting.");
                Environment.Exit(1);
            }

            // Process Input File
            if (!ProcessInputFile.ParseFile())
            {
                Console.WriteLine(" --> Error parsing input file - quiting.");
                Environment.Exit(2);
            }

            // Create and Initialize RNG
            byte[] byteArray = new byte[1024];
            using (var provider = new RNGCryptoServiceProvider())
            {
                provider.GetBytes(byteArray);
            }
            StaticRng.Rng = new Gjrand(ref byteArray);

            Complex[] values = new Complex[4];
            values[0] = new Complex(1.1, 1.1);
            values[1] = new Complex(2.1, 2.1);
            values[2] = new Complex(-3.3, -2.2);
            values[3] = new Complex(4.4, -1.1);

            Combiner c = CombinerFactory.Create();
            var      r = c.Evaluate(ref values);

            Console.WriteLine($"{r}");
        }
Beispiel #20
0
        public void GeneratePropHelpTest()
        {
            var parser    = new CmdLineParser <TestCmdLineObj>();
            var results   = parser.Parse(new string[] { });
            var generator = new HelpGenerator(results);

            var help = generator.GetPropertyHelp(results.Properties["Name"]);

            Assert.That.Contains("/Name <String> REQUIRED", help);
            Assert.That.Contains("\tTEST DESC", help);

            // Type doesn't have a description, but the flag is set to show it.
            help = generator.GetPropertyHelp(results.Properties["Type"]);
            Assert.That.Contains("/PersonType (/Type) <Father|Mother|Child>", help);
            Assert.That.Contains("\tDefault: Father", help);

            help = generator.GetPropertyHelp(results.Properties["Children"]);
            Assert.That.Contains("/Children", help);
            Assert.That.Contains("\tDefault: [\"One\", \"Two\", \"Three\"]", help);

            help = generator.GetPropertyHelp(results.Properties["Secret"]);
            Assert.That.Contains("/Secret", help);
            Assert.IsFalse(help.Contains("Shhh!"));
        }
Beispiel #21
0
        private void ParseCommandLineArguments()
        {
            string commandLine = CommandLineNoExecutableName();
            var    parseResult = _parser.Parse <CommandLineOptions>(commandLine);

            if (!parseResult.Success)
            {
                Bail(parseResult.Error);
            }
            _options = parseResult.Value;

            if (!String.IsNullOrEmpty(_options.OutputFileName))
            {
                try
                {
                    var filePrinter = new FilePrinter(_options.OutputFileName);
                    _context.Printer = filePrinter;
                }
                catch (IOException ex)
                {
                    Bail("Error creating output file: {0}", ex.Message);
                }
            }
        }
 public void ShouldParseParamsArg()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Arg("name").IsParams();
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     var input = parser.Parse(new[] { "value1", "value2" });
     input.Args.GetAll("name").ShouldBe(new[] { "value1", "value2" });
 }
 public void ShouldThrowIfMultipleUndefinedOptionsAreProvidedButNotAllowed()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     var settings = new CmdLineSettings { UndefinedOptionsPolicy = UndefinedOptionsPolicy.AllowSingleInstance };
     var parser = new CmdLineParser(builder.Definition, settings);
     Should.Throw<ParserException>(() => parser.Parse("-name", "-name")).Message.ShouldBe("Option 'name' is provided more than once.");
     var input = parser.Parse("-name:value1;value2");
     input.UndefinedOptions.GetSingle("name").ShouldBe(new[] { "value1", "value2" });
 }
 public void ShouldThrowIfFlagOptionHasValue()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Option("name");
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     Should.Throw<ParserException>(() => parser.Parse(new[] { "-name:value" }));
 }
 public void ShouldThrowIfRequiredOptionValueIsntProvided()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Option("name").IsRequired().Value("value");
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     Should.Throw<ParserException>(() => parser.Parse("-name"));
 }
 public void ShouldThrowIfRequiredArgIsntProvided()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     builder.Arg("name");
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     Should.Throw<Exception>(() => parser.Parse(new string[0]));
 }
 public void ShouldThrowIfUndefinedOptionIsProvidedButNotAllowed()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     var settings = new CmdLineSettings();
     var parser = new CmdLineParser(builder.Definition, settings);
     Should.Throw<ParserException>(() => parser.Parse("-foobar")).Message.ShouldBe("Unknown option 'foobar'.");
 }
Beispiel #28
0
        /// <summary>
        /// Parses the supplied command-line arguments.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="args"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static CmdLineParseResults <T> ParseArgs <T>(IEnumerable <string> args, CmdLineOptions options = null) where T : new()
        {
            var parser = new CmdLineParser <T>(options);

            return(parser.Parse(args));
        }
Beispiel #29
0
        static void Main(string[] args)
        {
            try {
                CmdLineParser cmdLineParser = new CmdLineParser("EosResourceCompiler v1.0");
                cmdLineParser.Add(new ArgumentDefinition("source", 1, "Archivo de entrada.", true));
                cmdLineParser.Add(new OptionDefinition("O", "Carpeta de salida."));
                cmdLineParser.Add(new OptionDefinition("V", "Muestra informacion detallada."));
                cmdLineParser.Add(new OptionDefinition("P", "Parametro personalizado.", false, true));

                if (args.Length == 0)
                {
                    Console.WriteLine(cmdLineParser.HelpText);
                    Console.ReadKey(true);
                }

                else
                {
                    CompilerParameters parameters = new CompilerParameters();

                    string outputFolder   = null;
                    string sourceFileName = null;

                    cmdLineParser.Parse(args);
                    foreach (OptionInfo optionInfo in cmdLineParser.Options)
                    {
                        switch (optionInfo.Name)
                        {
                        case "O":
                            outputFolder = optionInfo.Value;
                            break;

                        case "V":
                            parameters.Add("verbose");
                            break;

                        case "P":
                            parameters.Add(optionInfo.Value);
                            break;
                        }
                    }
                    foreach (ArgumentInfo argumentInfo in cmdLineParser.Arguments)
                    {
                        switch (argumentInfo.Name)
                        {
                        case "source":
                            sourceFileName = argumentInfo.Value;
                            break;
                        }
                    }

                    if (String.IsNullOrEmpty(sourceFileName))
                    {
                        throw new InvalidOperationException("No se especifico el fichero fuente.");
                    }

                    if (outputFolder == null)
                    {
                        outputFolder = Path.GetDirectoryName(sourceFileName);
                    }

                    ResourcePool resources;
                    using (Stream stream = new FileStream(
                               sourceFileName, FileMode.Open, FileAccess.Read, FileShare.None)) {
                        IResourceReader reader = new ResourceReader(stream);
                        resources = reader.Read();
                    }

                    IResourceCompiler compiler = new ResourceCompiler();
                    compiler.Compile(resources, outputFolder, parameters);
                }
            }

            catch (Exception e) {
                while (e != null)
                {
                    Console.WriteLine(e.Message);
                    e = e.InnerException;
                }
                Console.ReadKey(true);
            }
        }
Beispiel #30
0
        public void ExecuteOneCommand(string command)
        {
            InitParserIfNecessary();

            string[] parts = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length == 0)
            {
                return;
            }

            if (parts[0] == "#")
            {
                return; // Lines starting with # are comments
            }
            ICommand commandToExecute;

            if (IsInDbgEngNativeMode && parts[0] != "q")
            {
                commandToExecute = new DbgEngCommand()
                {
                    Command = command
                };
            }
            else
            {
                var parseResult = _commandParser.Parse(_allCommandTypes, command);
                if (!parseResult.Success)
                {
                    WriteErrorLine(parseResult.Error);
                    return;
                }
                if (parseResult.Value == null)
                {
                    return;
                }
                commandToExecute = (ICommand)parseResult.Value;
            }

            using (new TimeAndMemory(DisplayDiagnosticInformation, Printer))
            {
                try
                {
                    if (!IsCommandIsSupportedForThisTarget(commandToExecute.GetType()))
                    {
                        WriteErrorLine("This command is not supported for the current target type: '{0}'", TargetType);
                    }
                    else
                    {
                        commandToExecute.Execute(this);
                    }
                }
                catch (Exception ex)
                {
                    // Commands can throw exceptions occasionally. It's dangerous to continue
                    // after an arbitrary exception, but some of them are perfectly benign. We are
                    // taking the risk because there is no critical state that could become corrupted
                    // as a result of continuing.
                    WriteErrorLine("Exception during command execution -- {0}: '{1}'", ex.GetType().Name, ex.Message);
                    WriteErrorLine("\n" + ex.StackTrace);
                    WriteErrorLine("Proceed at your own risk, or restart the debugging session.");
                }
            }
            if (HyperlinkOutput && _temporaryAliases.Count > WarnThresholdCountOfTemporaryAliases)
            {
                WriteWarningLine("Hyperlinks are enabled. You currently have {0} temporary aliases. " +
                                 "Use .clearalias --temporary to clear them.", _temporaryAliases.Count);
            }
            Printer.CommandEnded();
        }
Beispiel #31
0
        public void ParseOneClass_OptionsAndRest()
        {
            ParseResult <OptionAndRest> result = _parser.Parse <OptionAndRest>("-a 123 alpha beta gamma");

            Assert.IsTrue(result.Success);
            Assert.IsNotNull(result.Value);
            Assert.AreEqual(123, result.Value.Option);
            Assert.AreEqual("alpha beta gamma", result.Value.Rest);
        }
Beispiel #32
0
        static void Main(string[] args)
        {
            //            try {
            CmdLineParser cmdLineParser = new CmdLineParser("FSMCompiler v1.0");

            cmdLineParser.Add(new ArgumentDefinition("source", 1, "Archivo de entrada.", true));
            cmdLineParser.Add(new OptionDefinition("G", "Generador."));
            cmdLineParser.Add(new OptionDefinition("H", "Ayuda."));
            cmdLineParser.Add(new OptionDefinition("P", "Parametro especifico del generador."));

            if (args.Length == 0)
            {
                Console.WriteLine(cmdLineParser.HelpText);
                Console.ReadKey(true);
            }

            else
            {
                string generatorName  = "C";
                string sourceFileName = "";
                GeneratorParameters generatorParameters = new GeneratorParameters();

                cmdLineParser.Parse(args);
                foreach (OptionInfo optionInfo in cmdLineParser.Options)
                {
                    switch (optionInfo.Name)
                    {
                    case "G":
                        generatorName = optionInfo.Value;
                        break;

                    case "P":
                        generatorParameters.Add(optionInfo.Value);
                        break;
                    }
                }
                foreach (ArgumentInfo argumentInfo in cmdLineParser.Arguments)
                {
                    switch (argumentInfo.Name)
                    {
                    case "source":
                        sourceFileName = argumentInfo.Value;
                        break;
                    }
                }

                Console.WriteLine();
                Console.WriteLine("FsmCompiler v1.1");
                Console.WriteLine("-------------------------------------------------------------");
                Console.WriteLine("  Finite state machine compiler tool.");
                Console.WriteLine("  Copyright 2015-2020 Rafael Serrano ([email protected])");
                Console.WriteLine();

                XmlLoader loader  = new XmlLoader();
                Machine   machine = loader.Load(sourceFileName);

                IGenerator generator = null;
                switch (generatorName)
                {
                case "DOT":
                    generator = new DOTGenerator(generatorParameters);
                    break;

                case "C":
                default:
                    generator = new CGenerator(generatorParameters);
                    break;

                case "CPP":
                    generator = new v1.Generator.CPP.CPPGenerator(generatorParameters);
                    break;
                }

                generator.Generate(machine);
            }

            /*          }
             *
             *        catch (Exception e) {
             *            while (e != null) {
             *                Console.WriteLine(e.Message);
             *                e = e.InnerException;
             *            }
             *        }*/
        }
 public void ShouldParseUndefinedOptionIfAllowed()
 {
     var builder = new CmdLineInputDefinitionBuilder();
     var settings = new CmdLineSettings { UndefinedOptionsPolicy = UndefinedOptionsPolicy.AllowSingleInstance };
     var parser = new CmdLineParser(builder.Definition, settings);
     var input = parser.Parse("-name:value1;value2");
     input.UndefinedOptions.GetSingle("name").ShouldBe(new[] { "value1", "value2" });
 }