Provides methods to parse command line arguments. Default implementation for CommandLine.ICommandLineParser.
Inheritance: ICommandLineParser
        public static Options GetOptions(string[] args)
        {
            var options = new Options();
            ICommandLineParser parser = new CommandLineParser();
            try
            {
                if (!parser.ParseArguments(args, options))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Error: was unable to parse some arguments");
                    Console.ResetColor();
                    Console.WriteLine(options.GetUsage());
                    Environment.Exit(-1);
                }
            }
            catch (ArgumentException ae)
            {
                if (ae.Message == "shortName")
                {
                    Console.Error.WriteLine("Short name attribute can't be NULL or Length > 1");
                }
            }

            if (string.IsNullOrWhiteSpace(options.Operation))
            {
                Console.WriteLine("Error parsing arguments: No <operation> option specified");
                Console.WriteLine(options.GetUsage());
                Environment.Exit(1);
            }
            return options;
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var configFileName = string.Empty;
            var unattendedMode = false;
            int numThreads = -1;

            var options = new CommandLineOptions();
            ICommandLineParser parser = new CommandLineParser();
            var writer = new StringWriter();
            if (parser.ParseArguments(args, options, writer))
            {
                configFileName = options.SessionFile;
                unattendedMode = options.Unattended;
                numThreads = options.NumberOfThreads;
            }
            if (writer.GetStringBuilder().Length > 0)
            {
                MessageBox.Show(writer.GetStringBuilder().ToString());
            }
            else
            {
                var f = new Form1(configFileName, unattendedMode, numThreads)
                {
                    StartPosition = FormStartPosition.CenterScreen
                };
                Application.Run(f);
            }
        }
        public static int Main(string[] args)
        {
            ICommandLineParser parser = new CommandLineParser();
            var options = new ProgramOptions();

            if (!parser.ParseArguments(args, options, Console.Error))
            {
                return 1;
            }

            // Archiving the source to a temporary file.
            string zipFileName = Path.GetTempFileName();
            ZipCompress(options.SourcePath, zipFileName, options.ArchivePassword, options.CompressionLevel);

            // Uploading the archive to Azure Storage.
            UploadFileToBlobStorage(zipFileName, options);

            // Removing the temporary file.
            try
            {
                File.Delete(zipFileName);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }

            return 0;
        }
Beispiel #4
0
 static void Main(string[] args)
 {
     Options commandLineOptions = new Options();
     ICommandLineParser commandParser = new CommandLineParser();
     if (commandParser.ParseArguments(args, commandLineOptions, Console.Error))
     {
         if (ValidateOptions(commandLineOptions))
         {
             try
             {
                 TaskProcessor concatTask = new TaskProcessor();
                 concatTask.ProcessTask(commandLineOptions);
             }
             catch (Exception ex)
             {
                 StringBuilder errorMessage = new StringBuilder();
                 errorMessage.AppendLine(messageUnexpectedError);
                 if (commandLineOptions.DebugMessages)
                 {
                     errorMessage.AppendFormat(messageUnhandledException, ex.ToString(), ex.Message, ex.StackTrace);
                 }
                 System.Console.Error.WriteLine(errorMessage.ToString());
                 Environment.ExitCode = 1;
             }
         }
     }
     else
     {
         // Command line params could not be parsed,
         // or help was requested
         Environment.ExitCode = -1;
     }
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            CommandLineOption options = new CommandLineOption();

            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings
            {
                MutuallyExclusive = true,
                CaseSensitive = true,
                HelpWriter = Console.Error
            });

            bool success = parser.ParseArguments(args, options);

            if (true == success)
            {
                Run(options.FileName, options.Overwrite);
            }
            else
            {
                if (args.Length != 0 && args[0] != "-h")
                {
                    NotifyAndExit("Input arguments are invalid. Type PostBuild.exe -h for help. Press any key to exit.");
                }
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            try
            {
                var options = new Options();
                var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
                if (!parser.ParseArguments(args, options))
                    Environment.Exit(1);

                using(var ctx = ZmqContext.Create())
                {
                    using (var socket = ctx.CreateSocket(SocketType.PULL))
                    {
                        foreach (var endPoint in options.bindEndPoints)
                            socket.Bind(endPoint);

                        while (true)
                        {
                            Thread.Sleep(options.delay);
                            var msg = socket.Receive(Encoding.UTF8);
                            Console.WriteLine("Received: " + msg);
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Beispiel #7
0
        static int Main(string[] args)
        {
            Options options = new Options();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true });
            if (!parser.ParseArguments(args, options))
            {
                return 1;
            }

            using (var output = options.OutputFile == null ? Console.Out : File.CreateText(options.OutputFile))
            {
                var file = options.Source;
                if (File.Exists(file))
                {
                    ProcessFile(file, file, options, output);
                }
                else if (Directory.Exists(file))
                {
                    var writer = new StringWriter();
                    ProcessDirectory(file, options, writer);
                    var text = writer.ToString();
                    WriteHeaders(text, options, output);
                    output.Write(text);
                }
                else
                {
                    Console.Error.WriteLine($"File not found: {file}");
                    return 1;
                }
            }
            return 0;
        }
Beispiel #8
0
        static void Main(params string[] args)
        {
            #if DEBUG
            Assembly.LoadFile(Path.Combine(Directory.GetCurrentDirectory(), "Aqueduct.Appia.Razor.dll"));
            #endif

            var options = new Options();
            ICommandLineParser parser = new CommandLineParser();
            parser.ParseArguments(args, options);

            if (string.IsNullOrEmpty(options.ExportPath) == false)
            {
                var exporter = new HtmlExporter(options.ExportPath,
                                                    new Configuration(),
                                                    new Aqueduct.Appia.Core.Bootstrapper())
                                                    { Verbose = options.Verbose };
                exporter.Initialise();
                exporter.Export();
            }
            else
            {
                var ip = options.Address == "*" ? IPAddress.Any : IPAddress.Parse(options.Address);
                var nancyHost = new NancyHost(ip, options.Port, new Aqueduct.Appia.Core.Bootstrapper());
                nancyHost.Start();

                Console.WriteLine(String.Format("Nancy now listening - navigate to http://{0}:{1}/. Press enter to stop", options.Address, options.Port));
                Console.ReadKey();

                nancyHost.Stop();

                Console.WriteLine("Stopped. Good bye!");
            }
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            try
            {
                var options = new Options();
                var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
                if (!parser.ParseArguments(args, options))
                    Environment.Exit(1);

                using(var ctx = ZmqContext.Create())
                {
                    using (ZmqSocket receiver = ctx.CreateSocket(SocketType.PULL),
                                        sender = ctx.CreateSocket(SocketType.PUSH))
                    {
                        receiver.Connect(options.pullEndPoint);
                        sender.Connect(options.pushEndPoint);

                        while (true)
                        {
                            var rcvdMsg = receiver.Receive(Encoding.UTF8);
                            Console.WriteLine("Pulled : " + rcvdMsg);
                            var sndMsg = options.rcvdMessageTag.Replace("#msg#", rcvdMsg);
                            Thread.Sleep(options.delay);
                            Console.WriteLine("Pushing: " + sndMsg);
                            sender.Send(sndMsg, Encoding.UTF8);
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            log = LogManager.GetLogger("UCSF.GrantLoader");

            try
            {
                Options options = new Options();
                ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
                if (!parser.ParseArguments(args, options))
                {
                    Options.ShowUsage();
                    Environment.Exit(1);
                }

                ExecTasks(options);
            #if DEBUG
                Console.ReadKey();
            #endif
            }
            catch(Exception ex)
            {
                log.Info("Unhandled exception.");
                log.Debug("Unhandled exception", ex);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Runs the compiler from the command line.
        /// </summary>
        /// <param name="arguments">The command line arguments. Each compiler defines its own.</param>
        /// <returns>0 for success, non-0 for error.</returns>
        private static int Main(string[] arguments)
        {
            CompilerOptions options = new CompilerOptions();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true });
            if (!parser.ParseArguments(arguments, options))
            {
                return 1;
            }

            var tzdbCompiler = new TzdbZoneInfoCompiler();
            var tzdb = tzdbCompiler.Compile(options.SourceDirectoryName);
            tzdb.LogCounts();
            if (options.ZoneId != null)
            {
                tzdb.GenerateDateTimeZone(options.ZoneId);
                return 0;
            }
            var windowsZones = CldrWindowsZonesParser.Parse(options.WindowsMappingFile);
            LogWindowsZonesSummary(windowsZones);
            var writer = CreateWriter(options);
            writer.Write(tzdb, windowsZones);

            if (options.OutputFileName != null)
            {
                Console.WriteLine("Reading generated data and validating...");
                var source = Read(options);
                source.Validate();
                if (options.TextDumpFile != null)
                {
                    CreateTextDump(source, options.TextDumpFile);
                }
            }
            return 0;
        }
Beispiel #12
0
        private static int Main(string[] args)
        {
            Options options = new Options();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true });
            if (!parser.ParseArguments(args, options))
            {
                return 1;
            }

            List<DateTimeZone> zones = LoadSource(options);
            zones = zones.OrderBy(zone => zone.Id, StringComparer.Ordinal).ToList();

            if (options.ZoneId != null)
            {
                var zone = zones.FirstOrDefault(z => z.Id == options.ZoneId);
                if (zone == null)
                {
                    throw new Exception($"Unknown zone ID: {options.ZoneId}");
                }
                DumpZone(zone, options);
            }
            else
            {
                foreach (var zone in zones)
                {
                    DumpZone(zone, options);
                    Console.Write("\r\n");
                }
            }

            return 0;
        }
Beispiel #13
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static int Main(string[] args)
        {
            try
            {
                var options = new SlaveOptions();
                var parser = new CommandLineParser();
                var helpWriter = new StringWriter();
                if (!parser.ParseArguments(args, options, helpWriter))
                {
                    MessageBox.Show(helpWriter.ToString(), "VMTool Slave");
                    return 1;
                }

                var server = new SlaveServer(options);
                if (options.Debug)
                {
                    GlobalContext.Properties["LogToConsole"] = "true";
                    server.Run();
                }
                else
                {
                    ServiceBase.Run(new SlaveService(server));
                }
                return 0;
            }
            catch (Exception ex)
            {
                log.Fatal("Fatal exception.", ex);
                return 1;
            }
        }
        static void Main(string[] arg)
        {
            var options = new Options();
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            //if (!parser.ParseArguments(args, options))
            //    Environment.Exit(1);

            //commandAssembly = Assembly.LoadFile(Environment.CurrentDirectory+ "\\CommonFunctions.dll");

            string commandArgs = null;

            HostFactory.Run(x =>                                 //1
            {
                x.AddCommandLineDefinition("arguments", f => { commandArgs = f; });
                x.ApplyCommandLine();

                Console.WriteLine(commandArgs);

                string[] args = commandArgs.Split(' ');

                parser.ParseArguments(args, options);
                x.Service<BowService>(s =>                        //2
                {
                    s.ConstructUsing(name => new BowService());     //3
                    s.WhenStarted(tc => tc.Start(options));              //4
                    s.WhenStopped(tc => tc.Stop());               //5
                });
                x.RunAsLocalSystem();                            //6

                x.SetDescription("Sample Bow Service Host");        //7
                x.SetDisplayName("BowService");                       //8
                x.SetServiceName("BowService");                       //9
            });                                                  //10
        }
        static void Main(string[] args)
        {
            ServicePointManager.UseNagleAlgorithm = false;

            Console.WriteLine(HeadingInfo);

            var options = new Options();

            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));

            if (!parser.ParseArguments(args, options))
            {
                Environment.Exit(1);
            }

            var client = new RestClient
                {
                    Authenticator = new HttpBasicAuthenticator(options.UserName, options.Password)
                };

            Root root = client.GetRoot(options.Server);

            Organisation org = client.GetOrganisation(root);

            Stopwatch watch = Stopwatch.StartNew();

            CreateAllRelationships(client, root, options, org);

            Console.WriteLine("Completed in {0} - press enter to exit.", watch.Elapsed);

            Console.ReadLine();

            Environment.Exit(0);
        }
        public Command Parse(string inputString)
        {
            if (String.IsNullOrEmpty(inputString))
            {
                throw new CommandException("Emtpy command");
            }

            var commandAndParams = (from words in inputString
                    let split = inputString.Split(' ')
                    select new { Name = split.First(), Parameters = split.Skip(1) }).FirstOrDefault();

            if (commandAndParams == null)
            {
                throw new CommandException("Invalid Command");
            }

            var commandOptionsType =
                 Assembly.GetExecutingAssembly().GetType(string.Format("{0}.{1}.{2}CommandOptions", Assembly.GetExecutingAssembly().GetName().Name, "Commands.CommandOptions", commandAndParams.Name));

            if (commandOptionsType == null)
            {
                throw new CommandException("Invalid Command");
            }

            var commandParameters = Activator.CreateInstance(commandOptionsType);

            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(false));

            if (parser.ParseArguments(commandAndParams.Parameters.ToArray(), commandParameters))
            {
                return new Command() { Name = commandAndParams.Name, Parameters = commandParameters };
            }
            throw new CommandException("Invalid Command Parameters");
        }
Beispiel #17
0
        private static int Main(string[] args)
        {
            Options options = new Options();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true });
            if (!parser.ParseArguments(args, options))
            {
                return 1;
            }
            TzdbDateTimeZoneSource source = LoadSource(options.Source);
            var dumper = new ZoneDumper(source, options);
            try
            {
                using (var writer = options.OutputFile == null ? Console.Out : File.CreateText(options.OutputFile))
                {
                    dumper.Dump(writer);
                }
            }
            catch (UserErrorException e)
            {
                Console.Error.WriteLine($"Error: {e.Message}");
                return 1;
            }

            return 0;
        }        
Beispiel #18
0
        static void Main(string[] args)
        {
            var options = new Options();
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            if (!parser.ParseArguments(args, options))
                Environment.Exit(1);

            using (var context = ZmqContext.Create())
            {
                using (var socket = context.CreateSocket(SocketType.REP))
                {
                    foreach (var bindEndPoint in options.bindEndPoints)
                        socket.Bind(bindEndPoint);
                    while (true)
                    {
                        Thread.Sleep(options.delay);
                        var rcvdMsg = socket.Receive(Encoding.UTF8);
                        Console.WriteLine("Received: " + rcvdMsg);
                        var replyMsg = options.replyMessage.Replace("#msg#", rcvdMsg);
                        Console.WriteLine("Sending : " + replyMsg + Environment.NewLine);
                        socket.Send(replyMsg, Encoding.UTF8);
                    }
                }
            }
        }
Beispiel #19
0
        static void Main(string[] args)
        {
            var options = new Options();
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            try
            {
                if (!parser.ParseArguments(args, options))
                {
                    Console.Read();
                    Environment.Exit(0);
                }
            }
            catch (Exception ex)
            {
                errorPrompt("When parsing command line arguments an exception occurred:\n{0}", ex.Message);
            }

            if (options.writeMode)
            {
                writeDataMatrix(options);
                Console.Read();
                Environment.Exit(0);
            }

            if (options.readMode)
            {
                readDataMatrix(options);
                Console.Read();
                Environment.Exit(0);
            }
        }
Beispiel #20
0
        static void Main(string[] args)
        {
            var stopwatch = Stopwatch.StartNew();
            var kuduSyncOptions = new KuduSyncOptions();

            try
            {
                ICommandLineParser parser = new CommandLineParser();
                if (parser.ParseArguments(args, kuduSyncOptions))
                {
                    SetLogger(kuduSyncOptions);
                    new KuduSync(kuduSyncOptions).Run();
                }
                else
                {
                    throw new InvalidOperationException("Failed to parse arguments");
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error: " + ex.Message);
            }

            stopwatch.Stop();

            if (kuduSyncOptions.Perf)
            {
                Console.WriteLine("Time " + stopwatch.ElapsedMilliseconds);
            }
        }
Beispiel #21
0
        static void Main(string[] args)
        {
            ICommandLineParser parser = new CommandLineParser();
            if (!parser.ParseArguments(args, options))
            {
                Console.WriteLine(GetUsage());
                return;
            }

            SetupFailsafeTimer();
            SetupPageLoadTimer();
            SetupWebBrowser();

            if (options.Verbose)
            {
                Console.WriteLine("Capturing page at {0}x{1}.", options.Width, options.Height);
                Console.WriteLine("Requesting {0}.", options.Url);
            }

            wb.Navigate(options.Url);

            while (failsafeTimer.Enabled || pageLoadTimer.Enabled)
            {
                if (options.Verbose)
                {
                    Console.Write(".");
                }

                Application.DoEvents();
                System.Threading.Thread.Sleep(100);
            }
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            try
            {
                options = new Options();
                var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
                if (!parser.ParseArguments(args, options))
                    Environment.Exit(1);

                using (var ctx = ZmqContext.Create())
                {
                    var pubSocket = ctx.CreateSocket(SocketType.PUB);
                    pubSocket.Bind(options.pubEndpoint);
                    pubSocket.SendReady +=new EventHandler<SocketEventArgs>(pubSocket_SendReady);
                    var repSocket = ctx.CreateSocket(SocketType.REP);
                    repSocket.Bind(options.repEndpoint);
                    repSocket.SendReady +=new EventHandler<SocketEventArgs>(repSocket_SendReady);
                    repSocket.ReceiveReady +=new EventHandler<SocketEventArgs>(repSocket_ReceiveReady);
                    Poller poller = new Poller(new ZmqSocket[] {pubSocket, repSocket});
                    while (true)
                    {
                        poller.Poll();
                        if (options.maxMessage >= 0)
                            if (msgCptr > options.maxMessage)
                                Environment.Exit(0);
                    }
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Beispiel #23
0
 public static void Main(string[] args)
 {
     try
     {
         Options commandLineOptions = new Options();
         ICommandLineParser commandParser = new CommandLineParser();
         if (commandParser.ParseArguments(args, commandLineOptions, Console.Error))
         {
             if (ValidateOptions(commandLineOptions))
             {
                 RequestProcessor duplicateProcessor = new RequestProcessor();
                 duplicateProcessor.FindDuplicates(commandLineOptions);
             }
         }
         else
         {
             // Command line params could not be parsed,
             // or help was requested
             Environment.ExitCode = -1;
         }
     }
     catch
     {
         // Something totally unexpected happened -
         // catch the exception so the whole process
         // doesn't come crashing down if this is
         // being run in a batch file
         Console.Error.WriteLine(messageUnexpectedInternalError);
         Environment.ExitCode = -2;
     }
 }
Beispiel #24
0
        private static void ProcessArgs(string[] args)
        {
            _logger.InfoFormat("Processing args: {0}", string.Join(",", args));

            var options = new ConsoleOptions();
            ICommandLineParser parser = new CommandLineParser();

            if (parser.ParseArguments(args, options) && args.Length > 0)
            {
                if (options.ScheduleBackupTasks)
                {
                    var scheduleEngine = ObjectFactory.GetInstance<IScheduleManager>();

                    scheduleEngine.ScheduleBackupTasks();
                }

                if (options.UnScheduleBackupTasks)
                {
                    var scheduleEngine = ObjectFactory.GetInstance<IScheduleManager>();

                    scheduleEngine.RemoveScheduledBackupTasks();
                }

                if (options.RunBackups)
                {
                    var backupManager = ObjectFactory.GetInstance<IBackupManager>();

                    backupManager.RunBackups();
                }

                if (options.Info)
                {
                    var configResourceAccess = ObjectFactory.GetInstance<IConfigResourceAccess>();

                    System.Console.WriteLine("Amount of days to keep backups: {0}", configResourceAccess.GetBackupRetentionDays());
                    System.Console.WriteLine("Press any key to continue...");
                    System.Console.ReadKey();
                }
            }
            else
            {
                System.Console.WriteLine(options.GetUsage());
            }

            if (!options.RunSilent)
            {
                System.Console.WriteLine("Input arg or Enter to exit.");

                var input = System.Console.ReadLine();

                if (!string.IsNullOrWhiteSpace(input))
                {
                    var newArgs = new List<string>();
                    newArgs.Add(input);

                    ProcessArgs(newArgs.ToArray());
                }
            }
        }
Beispiel #25
0
        public static Options Create(string[] args, CommandLineParserSettings settings)
        {
            Options mailOptions = new Options();
            ICommandLineParser parser = new CommandLineParser(settings);

            parser.ParseArguments(args, mailOptions);
            return mailOptions;
        }
Beispiel #26
0
        public static DefaultOptions Create(string[] args)
        {
            string target = string.Empty;
            int i = 0;

            foreach (string str in args)
            {
                if (str.StartsWith("-t"))
                {
                    if (str.Length > 2)
                    {
                        target = str.Substring(2);
                        if (target.StartsWith("=") || target.StartsWith(":"))
                        {
                            target = target.Substring(1);
                        }
                    }
                    else
                    {
                        if (args.Length > i)
                        {
                            target = args[i + 1];
                        }
                    }
                }

                if (str.StartsWith("--target"))
                {
                    target = str.Substring(9);
                }

                i++;
            }

            DefaultOptions options;
            CommandLineParser parser = new CommandLineParser();
            switch (target)
            {
                case "mssql":
                    options = new MSSQL.Options();
                    if (parser.ParseArguments(args, options))
                        return options;
                    throw new Exception("Could not parse arguments.");
                case "mysql":
                    options = new MySQL.Options();
                    if (parser.ParseArguments(args, options))
                        return options;
                    throw new Exception("Could not parse arguments.");
                case "postgresql":
                    options = new PostgreSQL.Options();
                    if (parser.ParseArguments(args, options))
                        return options;
                    throw new Exception("Could not parse arguments.");
                default:
                    throw new Exception(string.Format("Target {0} is not valid.", target));
            }
        }
        public CommandOptions Process(string[] args)
        {
            var options = new CommandOptions();
            var parser = new CommandLineParser();

            parser.ParseArguments(args, options);

            return options;
        }
        protected override void OnStart(string[] arguments)
        {
            var parser = new CommandLineParser(new CommandLineParserSettings());
            var commandLineParameters = new CommandLineParameters();

            parser.ParseArguments(arguments, commandLineParameters);

            bottomShelfHost.Start(commandLineParameters);
        }
Beispiel #29
0
        static void Main(string[] args)
        {
            var options = new CommandLineOptions();
            var parser = new CommandLineParser(new CommandLineParserSettings { CaseSensitive = false, IgnoreUnknownArguments = true });
            var res = parser.ParseArguments(args, options);

            if (!res)
            {
                Console.WriteLine("check your parameters and try again");
                return;
            }

            //check to see if we have a language directive for the specified type
            LanguageConfig Language = Helpers.GetLanguage(options.FileType);

            if (Language == null)
            {
                Console.WriteLine("We don't know how to handle the requested type. You can add a definition to the language.json file and try again.");
                Environment.Exit(1);
            }

            //override settings
            App.Settings.BeVerbose = options.Verbose;

            DirectoryInfo OutputDirectory = null;

            if (!string.IsNullOrWhiteSpace(options.OutputFolder))
            {

                if (Path.IsPathRooted(options.OutputFolder))
                    OutputDirectory = new DirectoryInfo(options.OutputFolder);
                else
                    OutputDirectory = new DirectoryInfo(Path.Combine(options.Path, options.OutputFolder));
            }
            else
            {
                OutputDirectory = new DirectoryInfo(Path.Combine(options.Path, App.Settings.DefaultDocsFolderName));
            }

            //get a new job
            NoccoJob Job = new NoccoJob(new DirectoryInfo(options.Path), Language, options.FileType, OutputDirectory)
            {
                ProjectName = options.ProjectName,
                IndexFilename = !string.IsNullOrWhiteSpace(options.IndexFilename) ? options.IndexFilename : App.Settings.DefaultIndexFileName,
                GenerateInlineIndex = options.GenerateInlineIndex,
                GenerateIndexFile = options.GenerateFullIndex,
                TruncateOutputDirectory = options.Truncate
            };

            //begin processing
            Nocco.ProcessJob(Job);

            Helpers.LogMessages("Finished processing");

            Environment.Exit(0);
        }
Beispiel #30
-1
 static void Main(string[] args)
 {
     var options = new Options();
     var parser = new CommandLineParser();
     if (parser.ParseArguments(args, options))
     {
         if (!string.IsNullOrEmpty(options.Name))
         {
             switch(options.Name)
             {
                 case "ClassicObserver":
                     ClassicObserver();
                     break;
                 case "EventObserver":
                     EventObserver();
                     break;
                 case "Factory":
                     Factory();
                     break;
                 case "Combine":
                     Combine();
                     break;
                 default:
                     break;
             }
         }
     }
     else
     {
         Console.Write("No argument");
     }
     Console.ReadLine();
 }