예제 #1
0
        private static CompilerConfiguration GetConfigurationFromArguments(List <string> arguments)
        {
            var configuration = new CompilerConfiguration(DotlessConfiguration.Default);

            foreach (var arg in arguments)
            {
                if (arg.StartsWith("-"))
                {
                    if (arg == "-m" || arg == "--minify")
                    {
                        configuration.MinifyOutput = true;
                    }
                    else if (arg == "-h" || arg == "--help")
                    {
                        WriteHelp();
                        configuration.Help = true;
                        return(configuration);
                    }
                    else if (arg == "-w" || arg == "--watch")
                    {
                        configuration.Watch = true;
                    }
                    else if (arg.StartsWith("-D") && arg.Contains("="))
                    {
                        var split = arg.Substring(2).Split('=');
                        var key   = split[0];
                        var value = split[1];
                        ConsoleArgumentParameterSource.ConsoleArguments.Add(key, value);
                    }
                    else
                    {
                        Console.WriteLine("Unknown command switch {0}.", arg);
                    }
                }
            }
            arguments.RemoveAll(p => p.StartsWith("-"));
            return(configuration);
        }
예제 #2
0
        private static CompilerConfiguration GetConfigurationFromArguments(List<string> arguments)
        {
            var configuration = new CompilerConfiguration(DotlessConfiguration.GetDefault());

            foreach (var arg in arguments)
            {
                if (arg.StartsWith("-"))
                {
                    if (arg == "-m" || arg == "--minify")
                    {
                        configuration.MinifyOutput = true;
                    }
                    else if (arg == "-k" || arg == "--keep-first-comment")
                    {
                        configuration.KeepFirstSpecialComment = true;
                    }
                    else if (arg == "-d" || arg == "--debug")
                    {
                        configuration.Debug = true;
                    }
                    else if (arg == "-h" || arg == "--help" || arg == @"/?")
                    {
                        WriteHelp();
                        configuration.Help = true;
                        return configuration;
                    }
                    else if (arg == "-l" || arg == "--listplugins")
                    {
                        WritePluginList();
                        configuration.Help = true;
                        return configuration;
                    }
                    else if (arg == "-a" || arg == "--import-all-less")
                    {
                        configuration.ImportAllFilesAsLess = true;
                    }
                    else if (arg == "-c" || arg == "--inline-css")
                    {
                        configuration.InlineCssFiles = true;
                    }
                    else if (arg == "-w" || arg == "--watch")
                    {
                        configuration.Watch = true;
                    }
                    else if (arg.StartsWith("-D") && arg.Contains("="))
                    {
                        var split = arg.Substring(2).Split('=');
                        var key = split[0];
                        var value = split[1];
                        ConsoleArgumentParameterSource.ConsoleArguments.Add(key, value);
                    }
                    else if (arg.StartsWith("-r") || arg.StartsWith("--disable-url-rewriting"))
                    {
                        configuration.DisableUrlRewriting = true;
                    }
                    else if (arg.StartsWith("--root-path") && arg.Contains("="))
                    {
                        configuration.RootPath = arg.Split('=')[1];
                    }
                    else if (arg.StartsWith("-v") || arg.StartsWith("--disable-variable-redefines"))
                    {
                        configuration.DisableVariableRedefines = true;
                    }
                    else if (arg.StartsWith("-x") || arg.StartsWith("--disable-color-compression"))
                    {
                        configuration.DisableColorCompression = true;
                    }
                    else if (arg.StartsWith("-s") || arg.StartsWith("--strict-math"))
                    {
                        configuration.StrictMath = true;
                    }
                    else if (arg.StartsWith("-p:") || arg.StartsWith("--plugin:"))
                    {
                        var pluginName = arg.Substring(arg.IndexOf(':') + 1);
                        List<string> pluginArgs = null;
                        if (pluginName.IndexOf(':') > 0)
                        {
                            pluginArgs = pluginName.Substring(pluginName.IndexOf(':') + 1).Split(',').ToList();
                            pluginName = pluginName.Substring(0, pluginName.IndexOf(':'));
                        }

                        var pluginConfig = GetPluginConfigurators()
                            .Where(plugin => String.Compare(plugin.Name, pluginName, true) == 0)
                            .FirstOrDefault();

                        if (pluginConfig == null)
                        {
                            Console.WriteLine("Cannot find plugin {0}.", pluginName);
                            continue;
                        }

                        var pluginParams = pluginConfig.GetParameters();

                        foreach (var pluginParam in pluginParams)
                        {
                            var pluginArg = pluginArgs
                                .Where(argString => argString.StartsWith(pluginParam.Name + "="))
                                .FirstOrDefault();

                            if (pluginArg == null)
                            {
                                if (pluginParam.IsMandatory)
                                {
                                    Console.WriteLine("Missing mandatory argument {0} in plugin {1}.", pluginParam.Name, pluginName);
                                }
                                continue;
                            }
                            else
                            {
                                pluginArgs.Remove(pluginArg);
                            }

                            pluginParam.SetValue(pluginArg.Substring(pluginParam.Name.Length + 1));
                        }

                        if (pluginArgs.Count > 0)
                        {
                            for (int i = 0; i < pluginArgs.Count; i++)
                            {
                                Console.WriteLine("Did not recognise argument '{0}'", pluginArgs[i]);
                            }
                        }

                        pluginConfig.SetParameterValues(pluginParams);
                        configuration.Plugins.Add(pluginConfig);
                    }
                    else
                    {
                        Console.WriteLine("Unknown command switch {0}.", arg);
                    }
                }
            }
            arguments.RemoveAll(p => p.StartsWith("-"));
            return configuration;
        }
예제 #3
0
        private static CompilerConfiguration GetConfigurationFromArguments(List <string> arguments)
        {
            var configuration = new CompilerConfiguration(DotlessConfiguration.GetDefault());

            foreach (var arg in arguments)
            {
                if (arg.StartsWith("-"))
                {
                    if (arg == "-m" || arg == "--minify")
                    {
                        configuration.MinifyOutput = true;
                    }
                    else if (arg == "-d" || arg == "--debug")
                    {
                        configuration.Debug = true;
                    }
                    else if (arg == "-h" || arg == "--help" || arg == @"/?")
                    {
                        WriteHelp();
                        configuration.Help = true;
                        return(configuration);
                    }
                    else if (arg == "-l" || arg == "--listplugins")
                    {
                        WritePluginList();
                        configuration.Help = true;
                        return(configuration);
                    }
                    else if (arg == "-a" || arg == "--import-all-less")
                    {
                        configuration.ImportAllFilesAsLess = true;
                    }
                    else if (arg == "-c" || arg == "--inline-css")
                    {
                        configuration.InlineCssFiles = true;
                    }
                    else if (arg == "-w" || arg == "--watch")
                    {
                        configuration.Watch = true;
                    }
                    else if (arg.StartsWith("-D") && arg.Contains("="))
                    {
                        var split = arg.Substring(2).Split('=');
                        var key   = split[0];
                        var value = split[1];
                        ConsoleArgumentParameterSource.ConsoleArguments.Add(key, value);
                    }
                    else if (arg.StartsWith("-r") || arg.StartsWith("--disable-url-rewriting"))
                    {
                        configuration.DisableUrlRewriting = true;
                    }
                    else if (arg.StartsWith("-p:") || arg.StartsWith("--plugin:"))
                    {
                        var           pluginName = arg.Substring(arg.IndexOf(':') + 1);
                        List <string> pluginArgs = null;
                        if (pluginName.IndexOf(':') > 0)
                        {
                            pluginArgs = pluginName.Substring(pluginName.IndexOf(':') + 1).Split(',').ToList();
                            pluginName = pluginName.Substring(0, pluginName.IndexOf(':'));
                        }

                        var pluginConfig = GetPluginConfigurators()
                                           .Where(plugin => String.Compare(plugin.Name, pluginName, true) == 0)
                                           .FirstOrDefault();

                        if (pluginConfig == null)
                        {
                            Console.WriteLine("Cannot find plugin {0}.", pluginName);
                            continue;
                        }

                        var pluginParams = pluginConfig.GetParameters();

                        foreach (var pluginParam in pluginParams)
                        {
                            var pluginArg = pluginArgs
                                            .Where(argString => argString.StartsWith(pluginParam.Name + "="))
                                            .FirstOrDefault();

                            if (pluginArg == null)
                            {
                                if (pluginParam.IsMandatory)
                                {
                                    Console.WriteLine("Missing mandatory argument {0} in plugin {1}.", pluginParam.Name, pluginName);
                                }
                                continue;
                            }
                            else
                            {
                                pluginArgs.Remove(pluginArg);
                            }

                            pluginParam.SetValue(pluginArg.Substring(pluginParam.Name.Length + 1));
                        }

                        if (pluginArgs.Count > 0)
                        {
                            for (int i = 0; i < pluginArgs.Count; i++)
                            {
                                Console.WriteLine("Did not recognise argument '{0}'", pluginArgs[i]);
                            }
                        }

                        pluginConfig.SetParameterValues(pluginParams);
                        configuration.Plugins.Add(pluginConfig);
                    }
                    else
                    {
                        Console.WriteLine("Unknown command switch {0}.", arg);
                    }
                }
            }
            arguments.RemoveAll(p => p.StartsWith("-"));
            return(configuration);
        }
예제 #4
0
파일: Program.cs 프로젝트: mhh/dotless
        private static CompilerConfiguration GetConfigurationFromArguments(List<string> arguments)
        {
            var configuration = new CompilerConfiguration(DotlessConfiguration.Default);

            foreach (var arg in arguments)
            {
                if (arg.StartsWith("-"))
                {
                    if (arg == "-m" || arg == "--minify")
                    {
                        configuration.MinifyOutput = true;
                    }
                    else if (arg == "-l" || arg == "--limit")
                    {
                        configuration.RuleLimit = 4095;
                    }
                    else if (arg == "-h" || arg == "--help")
                    {
                        WriteHelp();
                        configuration.Help = true;
                        return configuration;
                    }
                    else if (arg == "-w" || arg == "--watch")
                    {
                        configuration.Watch = true;
                    }
                    else if (arg.StartsWith("-D") && arg.Contains("="))
                    {
                        var split = arg.Substring(2).Split('=');
                        var key = split[0];
                        var value = split[1];
                        ConsoleArgumentParameterSource.ConsoleArguments.Add(key, value);
                    }
                    else
                    {
                        Console.WriteLine("Unknown command switch {0}.", arg);
                    }
                }
            }
            arguments.RemoveAll(p => p.StartsWith("-"));
            return configuration;
        }
예제 #5
0
        private static CompilerConfiguration GetConfigurationFromArguments(List<string> arguments)
        {
            var configuration = new CompilerConfiguration(DotlessConfiguration.Default);

            foreach (var arg in arguments)
            {
                if (arg.StartsWith("-"))
                {
                    if (arg == "-m" || arg == "--minify")
                    {
                        configuration.MinifyOutput = true;
                    }
                    else if (arg == "-h" || arg == "--help")
                    {
                        WriteHelp();
                        configuration.Help = true;
                        return configuration;
                    }
                    else if (arg == "-r" || arg == "--rescurse")
                    {
                        configuration.Recurse = true;
                    }
                    else if (arg == "-p" || arg == "--parallel")
                    {
                        configuration.CompileInParallel = true;
                    }
                    else if (arg == "-t" || arg == "--time")
                    {
                        configuration.TimeCompilation = true;
                    }
                    else if (arg == "-s" || arg == "--silent")
                    {
                        configuration.SilenceLogging = true;
                    }
                    else if (arg.StartsWith("-D") && arg.Contains("="))
                    {
                        var split = arg.Substring(2).Split('=');
                        var key = split[0];
                        var value = split[1];
                        ConsoleArgumentParameterSource.ConsoleArguments.Add(key, value);
                    }
                    else
                    {
                        Console.WriteLine("Unknown command switch {0}.", arg);
                    }
                }
            }
            arguments.RemoveAll(p => p.StartsWith("-"));
            return configuration;
        }