Ejemplo n.º 1
0
 public IConfig Parse(string[] args)
 {
     var config = new ManualConfig();
     foreach (var arg in args.Where(arg => arg.Contains("=")))
     {
         var split = arg.ToLowerInvariant().Split('=');
         var values = split[1].Split(',');
         switch (split[0])
         {
             case "jobs":
                 foreach (var value in values)
                     config.Add(ParseJobs(value));
                 break;
             case "columns":
                 foreach (var value in values)
                     config.Add(ParseColumns(value));
                 break;
             case "exporters":
                 break;
             case "diagnosers":
                 break;
             case "analysers":
                 break;
             case "loggers":
                 break;
         }
     }
     return config;
 }
Ejemplo n.º 2
0
 public static ManualConfig Union(IConfig globalConfig, IConfig localConfig)
 {
     var manualConfig = new ManualConfig();
     switch (localConfig.UnionRule)
     {
         case ConfigUnionRule.AlwaysUseLocal:
             manualConfig.Add(localConfig);
             break;
         case ConfigUnionRule.AlwaysUseGlobal:
             manualConfig.Add(globalConfig);
             break;
         case ConfigUnionRule.Union:
             manualConfig.Add(globalConfig);
             manualConfig.Add(localConfig);
             break;
     }
     return manualConfig;
 }
 public static ManualConfig Union(IConfig globalConfig, IConfig localConfig)
 {
     var manualConfig = new ManualConfig();
     switch (localConfig.UnionRule)
     {
         case ConfigUnionRule.AlwaysUseLocal:
             manualConfig.Add(localConfig);
             break;
         case ConfigUnionRule.AlwaysUseGlobal:
             manualConfig.Add(globalConfig);
             break;
         case ConfigUnionRule.Union:
             manualConfig.Add(globalConfig);
             manualConfig.Add(localConfig);
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return manualConfig;
 }
Ejemplo n.º 4
0
        public static ManualConfig Union(IConfig globalConfig, IConfig localConfig)
        {
            var manualConfig = new ManualConfig();

            switch (localConfig.UnionRule)
            {
            case ConfigUnionRule.AlwaysUseLocal:
                manualConfig.Add(localConfig);
                break;

            case ConfigUnionRule.AlwaysUseGlobal:
                manualConfig.Add(globalConfig);
                break;

            case ConfigUnionRule.Union:
                manualConfig.Add(globalConfig);
                manualConfig.Add(localConfig);
                break;
            }
            return(manualConfig);
        }
Ejemplo n.º 5
0
        public IConfig Parse(string[] args)
        {
            var config = new ManualConfig();

            foreach (var arg in args.Where(arg => arg.Contains("=")))
            {
                var split  = arg.ToLowerInvariant().Split('=');
                var values = split[1].Split(',');
                switch (split[0])
                {
                case "jobs":
                    foreach (var value in values)
                    {
                        config.Add(ParseJobs(value));
                    }
                    break;

                case "columns":
                    foreach (var value in values)
                    {
                        config.Add(ParseColumns(value));
                    }
                    break;

                case "exporters":
                    break;

                case "diagnosers":
                    break;

                case "analysers":
                    break;

                case "loggers":
                    break;
                }
            }
            return(config);
        }
Ejemplo n.º 6
0
        public static ManualConfig Union(IConfig globalConfig, IConfig localConfig)
        {
            var manualConfig = new ManualConfig();

            switch (localConfig.UnionRule)
            {
            case ConfigUnionRule.AlwaysUseLocal:
                manualConfig.Add(localConfig);
                break;

            case ConfigUnionRule.AlwaysUseGlobal:
                manualConfig.Add(globalConfig);
                break;

            case ConfigUnionRule.Union:
                manualConfig.Add(globalConfig);
                manualConfig.Add(localConfig);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(manualConfig);
        }
Ejemplo n.º 7
0
        public IConfig Parse(string[] args)
        {
            var config = new ManualConfig();

            for (int i = 0; i < args.Length; i++)
            {
                var arg = args[i]
                          .ToLowerInvariant()                   // normalize
                          .Replace(optionPrefix, string.Empty); // Allow both "--arg=<value>" and "arg=<value>" (i.e. with and without the double dashes)

                var containsEqualitySign = arg.Contains('=');
                if (!containsEqualitySign && !arg.EndsWith("s"))
                {
                    arg += "s"; // make it plural
                }
                bool isArgument = containsEqualitySign ||
                                  (configuration.ContainsKey(arg) && i + 1 < args.Length); // make sure we know it and there is next value

                if (!isArgument)
                {
                    continue;
                }

                var argumentName = containsEqualitySign ? arg.Split('=')[0] : arg;
                var values       = (containsEqualitySign ? arg.Split('=')[1] : args[++i]).Split(',');

                // Delibrately allow both "job" and "jobs" to be specified, makes it easier for users!!
                var argument = argumentName.EndsWith("s") ? argumentName : argumentName + "s";

                argument = argument.StartsWith(optionPrefix) ? argument.Remove(0, 2) : argument;

                switch (argument)
                {
                case "categorys":     // for now all the argument names at the place end with "s"
                case "allcategories":
                    config.Add(new AllCategoriesFilter(values));
                    break;

                case "anycategories":
                    config.Add(new AnyCategoriesFilter(values));
                    break;
                }

                if (configuration.ContainsKey(argument) == false)
                {
                    continue;
                }

                if (values.Length == 1 && values[0] == "all")
                {
                    configuration[argument].ProcessAllOptions(config);
                }
                else
                {
                    var processOption = configuration[argument].ProcessOption;
                    foreach (var value in values)
                    {
                        processOption(config, value);
                    }
                }
            }
            return(config);
        }
Ejemplo n.º 8
0
 public static ManualConfig Create(IConfig config)
 {
     var manualConfig = new ManualConfig();
     manualConfig.Add(config);
     return manualConfig;
 }