コード例 #1
0
ファイル: StartupManager.cs プロジェクト: mff-uk/xcase
        /// <summary>
        /// Processes the command line.
        /// </summary>
        /// <param name="args">Command line arguments</param>
        private void ProcessCommandLine(string[] args)
        {
            CommandLineParser.CommandLineParser parser = new CommandLineParser.CommandLineParser();
            parser.ShowUsageOnEmptyCommandline = false;
            parser.ExtractArgumentAttributes(this);
            parser.FillDescFromResource((CommandLineParser.IResource) new CommandlineArguments());

#if testingconsole
            args = new string[]
            {
                "--project",
                @"D:\Programování\XCase\Test\ABCCompany.XCase",
                //"--outputDir",
                //@"D:\Programování\XCase\Test\cmdoutput\",
                //"-d",
                //"0;1",
                // "-d",
                //"2(filename2)",
                //"-d",
                //"TransportDetailFormat(filename5)[I]"
                //"1-3(filename1,filename2,filename3)[I]"
                //"3"
            };
            //args = new string[] {"-i", "asdf"};
#endif
            try
            {
                parser.ParseCommandLine(args);
            }
            catch (CommandLineParser.Exceptions.CommandLineException e)
            {
                Console.WriteLine("Error in command line parameters: ");
                Console.WriteLine(e.Message);
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Correct usage: ");
                parser.ShowUsage();
                ShutDown();
                return;
            }

            #region List and Help

            if (Help)
            {
                HelpAndShutdown(parser);
                return;
            }

            // povolena kombinace list + project
            if (List)
            {
                ListAndShutdown();
                return;
            }

            #endregion

            Export();
        }
コード例 #2
0
        private static CommandLineOptions ProcessComandLineParameters(string[] args)
        {
            var options           = new CommandLineOptions();
            var commandLineParser = new CommandLineParser.CommandLineParser
            {
                ShowUsageOnEmptyCommandline = true,
                AcceptSlash = true,
                IgnoreCase  = true,
            };

            commandLineParser.ExtractArgumentAttributes(options);
            if (!args.Any() || args.Any(c => showUsageCommands.Contains(c)))
            {
                LocalizationManager.Instance.AssignCurrentCulture();
                commandLineParser.FillDescFromResource(new CmdResources());
            }

            try
            {
                commandLineParser.ParseCommandLine(args);
            }
            catch (CommandLineException)
            {
                throw new CommandLineException("Incorrect command line parameters");
            }

            return(options);
        }