Example #1
0
        static void Main(string[] args)
        {

            JsonConvert.DefaultSettings = () =>
            {
                var settings = new JsonSerializerSettings();
                settings.Formatting = Formatting.Indented;
                settings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
                settings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());

                return settings;
            };


            var options = new CommandOptions();
            
            


            string verbName = "";
            object verbOptions = null;

            if (!CommandLine.Parser.Default.ParseArguments(args, options, (verb, obj) =>
                {
                    verbName = verb;
                    verbOptions = obj;
                }))
            {
                Console.WriteLine("Failed to parse console args");

                HelpText text = new HelpText();
                
                if(options.BuilderOptions != null)
                {
                    Console.WriteLine(text.RenderParsingErrorsText(options.BuilderOptions, 1));
                }

                if (options.UpdaterOptions != null)
                {
                    Console.WriteLine(text.RenderParsingErrorsText(options.UpdaterOptions, 1));
                }

                Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);
            }

            if (verbName == "createBuild")
            {
                BuilderOptions op = verbOptions as BuilderOptions;

                CreateBuild(op);
            }
            else if (verbName == "update")
            {
                UpdaterOptions op = verbOptions as UpdaterOptions;

                DownloadLatestVersion(op);
            }

        }