예제 #1
0
파일: Program.cs 프로젝트: helgihaf/Grocker
        private static Watcher CreateWatcherWithOptions(Options options)
        {
            var watcher = new Watcher();

            watcher.DirectoryPath = options.DirectoryPath ?? Environment.CurrentDirectory;
            watcher.Filter = options.Filter ?? "*.log";
            watcher.LineWriter = CreateWriter(options);

            return watcher;
        }
예제 #2
0
파일: Program.cs 프로젝트: helgihaf/Grocker
        private static ILineWriter CreateWriter(Options options)
        {
            var writer = new ConsoleLineWriter();

            if (options.EnableColorSchema)
            {
                EnableColorSchema(writer, options);
            }
            else
            {
                writer.AutoDetectColorSchema = false;
            }

            return writer;
        }
예제 #3
0
파일: Options.cs 프로젝트: helgihaf/Grocker
        private static Options CreateOptions(CommandLineParameters parameters)
        {
            var options = new Options();
            options.HelpWanted = parameters.DetachNamedBool("?");
            if (options.HelpWanted)
            {
                return options;
            }

            options.DirectoryPath = parameters.DetachPositional();
            options.Filter = parameters.DetachNamed("f");
            options.EnableColorSchema = !parameters.DetachNamedBool("nc");
            options.ColorSchemaName = parameters.DetachNamed("c");
            if (!options.EnableColorSchema && !string.IsNullOrEmpty(options.ColorSchemaName))
            {
                throw new ArgumentException("Options nc and c are incompatible with each other");
            }

            return options;
        }
예제 #4
0
파일: Program.cs 프로젝트: helgihaf/Grocker
 private static void EnableColorSchema(ConsoleLineWriter writer, Options options)
 {
     var colorSchemas = LoadColorSchemas();
     if (colorSchemas == null)
     {
         throw new ApplicationException("No color schema file found");
     }
     if (options.ColorSchemaName == null)
     {
         writer.AutoDetectColorSchema = true;
         writer.ColorSchemas = colorSchemas;
     }
     else
     {
         writer.AutoDetectColorSchema = false;
         writer.ColorSchema = colorSchemas.Find(cs => cs.Name == options.ColorSchemaName);
         if (writer.ColorSchema == null)
         {
             throw new ApplicationException(string.Format("Color schema {0} was not found.", options.ColorSchemaName));
         }
     }
 }