public HandlerResponseMessage Handle(CommandLineRequestMessage request)
        {
            if (request.CommandLineOptions.Args.Length == 0)
            {
                var strategy = new PrintUsageStrategy(reporter);
                strategy.HandleCommandLineOptions(request.CommandLineOptions);
                return(new HandlerResponseMessage(false, false));
            }

            if (request.CommandLineOptions.Help)
            {
                var strategy = new PrintUsageStrategy(reporter);
                return(strategy.HandleCommandLineOptions(request.CommandLineOptions));
            }

            if (request.CommandLineOptions.Version)
            {
                var strategy = new PrintVersionStrategy(reporter);
                return(strategy.HandleCommandLineOptions());
            }

            if (request.CommandLineOptions.PrintConfig)
            {
                var strategy = new PrintConfigStrategy(reporter, configReader);
                return(strategy.HandleCommandLineOptions(request.CommandLineOptions));
            }

            if (!string.IsNullOrWhiteSpace(request.CommandLineOptions.ConfigFile))
            {
                var strategy = new LoadConfigFileStrategy(reporter, fileSystemWrapper);
                return(strategy.HandleCommandLineOptions(request.CommandLineOptions));
            }

            if (request.CommandLineOptions.Init)
            {
                var strategy = new CreateConfigFileStrategy(reporter, configFileGenerator, fileSystemWrapper);
                return(strategy.HandleCommandLineOptions(request.CommandLineOptions));
            }

            if (request.CommandLineOptions.ListPlugins)
            {
                var strategy = new PrintPluginsStrategy(reporter, configReader);
                return(strategy.HandleCommandLineOptions(request.CommandLineOptions));
            }

            if (request.CommandLineOptions.LintPath.Any())
            {
                var strategy = new ValidatePathStrategy(reporter, fileSystemWrapper);
                return(strategy.HandleCommandLineOptions(request.CommandLineOptions));
            }
            else
            {
                var strategy = new PrintUsageStrategy(reporter);
                return(strategy.HandleCommandLineOptions(request.CommandLineOptions));
            }
        }
Example #2
0
 public void HandleCommandLineOptions(CommandLineOptions commandLineOptions)
 {
     if (commandLineOptions.Args.Length == 0 || commandLineOptions.Help)
     {
         var strategy = new PrintUsageStrategy(reporter);
         strategy.HandleCommandLineOptions(commandLineOptions);
     }
     else if (commandLineOptions.Version)
     {
         var strategy = new PrintVersionStrategy(reporter);
         strategy.HandleCommandLineOptions();
     }
     else if (commandLineOptions.PrintConfig)
     {
         var strategy = new PrintConfigStrategy(reporter, configReader);
         strategy.HandleCommandLineOptions(commandLineOptions);
     }
     else if (!string.IsNullOrWhiteSpace(commandLineOptions.ConfigFile))
     {
         var strategy = new LoadConfigFileStrategy(reporter);
         strategy.HandleCommandLineOptions(commandLineOptions);
     }
     else if (commandLineOptions.Init)
     {
         var strategy = new CreateConfigFileStrategy(reporter, configFileGenerator);
         strategy.HandleCommandLineOptions(commandLineOptions);
     }
     else if (this.commandLineOptions.ListPlugins)
     {
         var strategy = new PrintPluginsStrategy(reporter, configReader);
         strategy.HandleCommandLineOptions(commandLineOptions);
     }
     else if (!this.commandLineOptions.LintPath.Any())
     {
         var strategy = new PrintUsageStrategy(reporter);
         strategy.HandleCommandLineOptions(commandLineOptions);
     }
 }