<commit_before>﻿using System;
using System.Reflection;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;

using CL = CommandLine; //Avoid type name conflict with external CommandLine library
using CO = Colorful;

namespace Alpheus.CommandLine
{
    class Program
    {
        public enum ExitCodes
        {
            SUCCESS = 0,
            INVALID_ARGUMENTS,
            NO_PACKAGE_MANAGER,
            ERROR_SCANNING_FOR_PACKAGES,
            ERROR_SEARCHING_OSS_INDEX,
            ERROR_SCANNING_SERVER_VERSION,
            ERROR_SCANNING_SERVER_CONFIGURATION
        }

        static Options ProgramOptions = new Options();

        static ConfigurationFile<KeyValueSection, KeyValueNode> SourceFile { get; set; }

        static CO.Figlet figlet = new CO.Figlet(CO.FigletFont.Load("chunky.flf"));
        static int Main(string[] args)
        {
            #region Handle command line options
            Dictionary<string, object> al_options = new Dictionary<string, object>();
            if (!CL.Parser.Default.ParseArguments(args, ProgramOptions))
            {
                return (int)ExitCodes.INVALID_ARGUMENTS;
            }
            else
            {
                if (!string.IsNullOrEmpty(ProgramOptions.File))
                {
                    if (!File.Exists(ProgramOptions.File))
                    {
                        PrintErrorMessage("Error in parameter: Could not find file {0}.", ProgramOptions.File);
                        return (int)ExitCodes.INVALID_ARGUMENTS;
                    }
                    else
                    {
                        al_options.Add("File", ProgramOptions.File);
                    }
                }

            }
            #endregion

            #region Handle command line verbs
            CL.Parser.Default.ParseArguments(args, ProgramOptions, (verb, options) =>
            {
                try
                {
                    if (verb == "mysql")
                    {
                        SourceFile = new MySQL((string)al_options["File"], true, true);
                        if (SourceFile.LastException != null)
                        {
                            if (SourceFile.LastIOException != null)
                            {
                                PrintErrorMessage(SourceFile.LastIOException);
                            }
                            else if (SourceFile.LastException != null)
                            {
                                PrintErrorMessage(SourceFile.LastException);
                            }

                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    PrintErrorMessage(ae);
                    return;
                }
                catch (Exception e)
                {
                    PrintErrorMessage(e);
                    return;
                }
            });

            if (SourceFile == null)
            {
                Console.WriteLine("No configuration source file specified or error parsing options.");
                return (int)ExitCodes.INVALID_ARGUMENTS;
            }
            #endregion
            PrintBanner();
            PrintXml(SourceFile.ConfigurationTree.Xml);
            return (int)ExitCodes.SUCCESS;
        }

        static void PrintXml(XDocument xml)
        {
            CO.Console.WriteLine(xml.ToString());
        }

        static void PrintBanner()
        {
            CO.Console.WriteLine(figlet.ToAscii("Alpheus"), Color.PaleGreen);
            CO.Console.WriteLine("v" + Assembly.GetExecutingAssembly().GetName().Version.ToString(), Color.PaleGreen);
        }

        static void PrintMessage(string format)
        {
            Console.Write(format);
        }

        static void PrintMessage(string format, params object[] args)
        {<commit_msg>Dpn't use CO in PrintBanner().<commit_after>﻿using System;
using System.Reflection;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;

using CL = CommandLine; //Avoid type name conflict with external CommandLine library
using CO = Colorful;

namespace Alpheus.CommandLine
{
    class Program
    {
        public enum ExitCodes
        {
            SUCCESS = 0,
            INVALID_ARGUMENTS,
            NO_PACKAGE_MANAGER,
            ERROR_SCANNING_FOR_PACKAGES,
            ERROR_SEARCHING_OSS_INDEX,
            ERROR_SCANNING_SERVER_VERSION,
            ERROR_SCANNING_SERVER_CONFIGURATION
        }

        static Options ProgramOptions = new Options();

        static ConfigurationFile<KeyValueSection, KeyValueNode> SourceFile { get; set; }

        static CO.Figlet figlet = new CO.Figlet(CO.FigletFont.Load("chunky.flf"));
        static int Main(string[] args)
        {
            #region Handle command line options
            Dictionary<string, object> al_options = new Dictionary<string, object>();
            if (!CL.Parser.Default.ParseArguments(args, ProgramOptions))
            {
                return (int)ExitCodes.INVALID_ARGUMENTS;
            }
            else
            {
                if (!string.IsNullOrEmpty(ProgramOptions.File))
                {
                    if (!File.Exists(ProgramOptions.File))
                    {
                        PrintErrorMessage("Error in parameter: Could not find file {0}.", ProgramOptions.File);
                        return (int)ExitCodes.INVALID_ARGUMENTS;
                    }
                    else
                    {
                        al_options.Add("File", ProgramOptions.File);
                    }
                }

            }
            #endregion

            #region Handle command line verbs
            CL.Parser.Default.ParseArguments(args, ProgramOptions, (verb, options) =>
            {
                try
                {
                    if (verb == "mysql")
                    {
                        SourceFile = new MySQL((string)al_options["File"], true, true);
                        if (SourceFile.LastException != null)
                        {
                            if (SourceFile.LastIOException != null)
                            {
                                PrintErrorMessage(SourceFile.LastIOException);
                            }
                            else if (SourceFile.LastException != null)
                            {
                                PrintErrorMessage(SourceFile.LastException);
                            }

                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    PrintErrorMessage(ae);
                    return;
                }
                catch (Exception e)
                {
                    PrintErrorMessage(e);
                    return;
                }
            });

            if (SourceFile == null)
            {
                Console.WriteLine("No configuration source file specified or error parsing options.");
                return (int)ExitCodes.INVALID_ARGUMENTS;
            }
            #endregion
            PrintBanner();
            PrintXml(SourceFile.ConfigurationTree.Xml);
            return (int)ExitCodes.SUCCESS;
        }

        static void PrintXml(XDocument xml)
        {
            CO.Console.WriteLine(xml.ToString());
        }

        static void PrintBanner()
        {
            //CO.Console.WriteLine(figlet.ToAscii("Alpheus"), Color.PaleGreen);
            Console.WriteLine("v" + Assembly.GetExecutingAssembly().GetName().Version.ToString(), Color.PaleGreen);
        }

        static void PrintMessage(string format)
        {
            Console.Write(format);
        }

        static void PrintMessage(string format, params object[] args)
        {
{'fraction_non_alphanumeric': 0.08035934038887521, 'fraction_numerical': 0.0004922471080482402, 'mean_word_length': 1.299009900990099, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '5424249', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1850, 'n_words': 386}