<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using Autofac;
using CommandLine;
using CommandLine.Text;
using MMDB.Shared;
//using Ninject;
using NLog;
using Sriracha.Deploy.AutofacModules;
using Sriracha.Deploy.Data;
using Sriracha.Deploy.Data.Deployment;
using Sriracha.Deploy.Data.ServiceJobs;
using Sriracha.Deploy.Data.SystemSettings;
using System.IO;
using System.Reflection;

namespace Sriracha.Deploy.Server
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>

		public class CommandLineOptions
		{
			[Option('d', "debug")]
			public bool Debug { get; set; }

			[Option("workingDirectory")]
			public string WorkingDirectory { get; set; }

			[Option("thrashmode")]
			public bool ThrashMode { get; set; }

            [Option("patchdata")]
            public bool PatchData { get; set; }

			[Option("cleanupFolders")]
			public bool CleanupFolders { get; set; }

            [Option("createOfflineDeployment")]
            public bool CreateOfflineDeployment { get; set; }

			[Option("runDeployment")]
			public string RunDeploymentId { get; set; }
			[ParserState]
			public IParserState LastParserState { get; set; }

			[HelpOption]
			public string GetUsage()
			{
				return HelpText.AutoBuild(this,
					(HelpText current) =>
						HelpText.DefaultParsingErrorsHandler(this, current));
			}

		}

		//private static IKernel _kernel { get; set; }
		private static IDIFactory _diFactory;
		private static Logger _logger { get; set; }

		static void Main(string[] args)
		{
			switch(AppConfigOptions.DIContainer)
			{
				case DIContainer.Ninject:
					{
						throw new NotSupportedException("Ninject is no longer supported");
						//var kernel = new StandardKernel(new NinjectModules.SrirachaNinjectorator());
						//_logger = kernel.Get<NLog.Logger>();
						//_diFactory = kernel.Get<IDIFactory>();
					}
					//break;
				case DIContainer.Autofac:
					{
						var builder = new ContainerBuilder();
						builder.RegisterModule(new SrirachaAutofacorator(EnumDIMode.Service));
						builder.RegisterType<WinService>().AsSelf();
						var container = builder.Build();
						_logger = container.Resolve<NLog.Logger>();
						_diFactory = container.Resolve<IDIFactory>();
					}
					break;
				default:
					throw new UnknownEnumValueException(AppConfigOptions.DIContainer);
			}
			SetupColorConsoleLogging();

			var options = new CommandLineOptions();
			if(!Parser.Default.ParseArguments(args, options))
			{<commit_msg>more detail for loader type exceptions<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using Autofac;
using CommandLine;
using CommandLine.Text;
using MMDB.Shared;
//using Ninject;
using NLog;
using Sriracha.Deploy.AutofacModules;
using Sriracha.Deploy.Data;
using Sriracha.Deploy.Data.Deployment;
using Sriracha.Deploy.Data.ServiceJobs;
using Sriracha.Deploy.Data.SystemSettings;
using System.IO;
using System.Reflection;

namespace Sriracha.Deploy.Server
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>

		public class CommandLineOptions
		{
			[Option('d', "debug")]
			public bool Debug { get; set; }

			[Option("workingDirectory")]
			public string WorkingDirectory { get; set; }

			[Option("thrashmode")]
			public bool ThrashMode { get; set; }

            [Option("patchdata")]
            public bool PatchData { get; set; }

			[Option("cleanupFolders")]
			public bool CleanupFolders { get; set; }

            [Option("createOfflineDeployment")]
            public bool CreateOfflineDeployment { get; set; }

			[Option("runDeployment")]
			public string RunDeploymentId { get; set; }
			[ParserState]
			public IParserState LastParserState { get; set; }

			[HelpOption]
			public string GetUsage()
			{
				return HelpText.AutoBuild(this,
					(HelpText current) =>
						HelpText.DefaultParsingErrorsHandler(this, current));
			}

		}

		//private static IKernel _kernel { get; set; }
		private static IDIFactory _diFactory;
		private static Logger _logger { get; set; }

		static void Main(string[] args)
		{
			switch(AppConfigOptions.DIContainer)
			{
				case DIContainer.Ninject:
					{
						throw new NotSupportedException("Ninject is no longer supported");
						//var kernel = new StandardKernel(new NinjectModules.SrirachaNinjectorator());
						//_logger = kernel.Get<NLog.Logger>();
						//_diFactory = kernel.Get<IDIFactory>();
					}
					//break;
				case DIContainer.Autofac:
					{  
                        try 
                        {
						    var builder = new ContainerBuilder();
						    builder.RegisterModule(new SrirachaAutofacorator(EnumDIMode.Service));
						    builder.RegisterType<WinService>().AsSelf();
						    var container = builder.Build();
						    _logger = container.Resolve<NLog.Logger>();
						    _diFactory = container.Resolve<IDIFactory>();
                        }
                        catch(ReflectionTypeLoadException err)
                        {
                            foreach(var loaderError in err.LoaderExceptions)
                            {
                                Console.WriteLine("LOADER EXCEPTION: " + loaderError.ToString());
                            }
                            throw;
                        }
					}
					break;
				default:
					throw new UnknownEnumValueException(AppConfigOptions.DIContainer);
			}
			SetupColorConsoleLogging();

			var options = new CommandLineOptions();
			if(!Parser.Default.ParseArguments(args, options))
			{
{'fraction_non_alphanumeric': 0.10665963802495168, 'fraction_numerical': 0.0, 'mean_word_length': 2.8485463150777552, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2865758', 'n_tokens_mistral': 1974, 'n_tokens_neox': 1629, 'n_words': 376}