Beispiel #1
0
        public void TestMethod1()
        {
            CLParser parser = new CLParser();

            CLSwitch apple = new CLSwitch('a', "apple", "Should I use apples?");

            parser.Add(apple);

            CLSwitch banana = new CLSwitch('b', "banana", "Should I use bananas?");

            parser.Add(banana);

            CLGenericArgument <Int32> integer = new CLGenericArgument <Int32>(Int32.Parse, 'i', "int", "This options has a long description, I am going to keep talking about this argument until I reach a good long length for this description");

            parser.Add(integer);

            CLEnumArgument <DayOfWeek> day = new CLEnumArgument <DayOfWeek>('d', "day", "The day of the week");

            parser.Add(day);

            parser.PrintUsage();


            parser.Parse(new String[] {
                "-a", "--day", "Sunday", "-b", "-i", "32", "43",
            });
            Assert.AreEqual(true, apple.set);
            Assert.AreEqual(true, banana.set);
            Assert.AreEqual(true, integer.set);
            Assert.AreEqual(true, day.set);
            Assert.AreEqual(DayOfWeek.Sunday, day.ArgValue);
        }
        public RemoteDataServerProgramOptions()
        {
            listenIPAddress = new CLGenericArgument <IPAddress>(IPAddress.Parse, 'l', "Listen IP Address");
            listenIPAddress.SetDefault(IPAddress.Parse("0.0.0.0"));
            Add(listenIPAddress);

            npcListenPort = new CLGenericArgument <UInt16>(UInt16.Parse, 'n', "NpcListenPort", "The TCP port that the NPC server will be listening to (If no port is specified, the NPC server will not be running)");
            Add(npcListenPort);

            logFile = new CLStringArgument('f', "LogFile", "Log file (logs to stdout if not specified)");
            Add(logFile);

            logLevel = new CLEnumArgument <LogLevel>('v', "LogLevel", "Level of statements to log");
            logLevel.SetDefault(LogLevel.None);
            Add(logLevel);
        }