コード例 #1
0
        public static bool InitAndSetup(string[] args)
        {
            SetToDefaults();

            if (OptionsParser.HelpRequested(args))
            {
                OptionsParser.DisplayHelp(typeof(Program).Assembly, false);
                return(false);
            }

            var unknownArgs = OptionsParser.Prepare(args, typeof(Program).Assembly, false).ToList();

            if (unknownArgs.Count > 0)
            {
                Console.WriteLine("Unknown arguments : ");
                foreach (var remain in unknownArgs)
                {
                    Console.WriteLine("\t {0}", remain);
                }

                return(false);
            }

            if (!ValidateArguments())
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
 public void TestHelpRequested_WhenNotRequested()
 {
     Assert.IsFalse(OptionsParser.HelpRequested(new[] { "--other", "--other2" }));
 }
コード例 #3
0
 public void TestHelpRequested_WhenRequested()
 {
     Assert.IsTrue(OptionsParser.HelpRequested(new[] { "--help" }));
     Assert.IsTrue(OptionsParser.HelpRequested(new[] { "--h" }));
     Assert.IsTrue(OptionsParser.HelpRequested(new[] { "--other", "--help" }));
 }