Beispiel #1
0
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Usage();
                return;
            }
            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i];
                switch (arg)
                {
                case "-?":
                case "--help":
                    Usage();
                    return;

                case "-c":
                case "--current":
                    printCurrent = true;
                    break;

                case "-l":
                case "--location":
                    SchemeManager.PrintSchemesDirectory();
                    return;

                case "-o":
                case "--output":
                    if (i + 1 < args.Length)
                    {
                        new IniSchemeWriter().ExportCurrentAsIni(args[i + 1]);
                    }
                    else
                    {
                        OutputUsage();
                    }
                    return;

                case "-s":
                case "--schemes":
                    SchemeManager.PrintSchemes();
                    return;

                case "-v":
                case "--version":
                    Version();
                    return;

                case "-e":
                case "--errors":
                    reportErrors = true;
                    break;

                case "-q":
                case "--quiet":
                    quietMode = true;
                    break;

                case "-d":
                case "--defaults":
                    setDefaults   = true;
                    setProperties = false;
                    break;

                case "-b":
                case "--both":
                    setDefaults   = true;
                    setProperties = true;
                    break;

                case "-x":
                case "--xterm":
                    setUnixStyle  = true;
                    setProperties = true;
                    break;

                case "-a":
                case "--allcolors":
                    compactTableStyle = false;
                    break;

                case "-t":
                case "--terminal":
                    setTerminalStyle = true;
                    setProperties    = true;
                    break;

                default:
                    break;
                }
            }
            if (printCurrent)
            {
                if (setUnixStyle)
                {
                    DoInVTMode(() => ColorTable.PrintTableWithVt(compactTableStyle));
                }
                else
                {
                    ColorTable.PrintTable(compactTableStyle);
                }
                return;
            }

            string schemeName = args[args.Length - 1];

            ColorScheme colorScheme = SchemeManager.GetScheme(schemeName, reportErrors);

            if (colorScheme == null)
            {
                Console.WriteLine(string.Format(Resources.SchemeNotFound, schemeName));
                return;
            }

            foreach (var target in GetConsoleTargets())
            {
                target.ApplyColorScheme(colorScheme, quietMode, compactTableStyle);
            }
        }
Beispiel #2
0
 private static void Usage()
 {
     Console.WriteLine(Resources.Usage,
                       string.Join($"{Environment.NewLine}  ", SchemeManager.GetParsers().Select(p => p.Name)));
 }