<commit_before>﻿/*
Poor Man's T-SQL Formatter - a small free Transact-SQL formatting 
library for .Net 2.0, written in C#. 
Copyright (C) 2011 <NAME>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
using NDesk.Options;

namespace PoorMansTSqlFormatterCmdLine
{
    class Program
    {
        private static FrameworkClassReplacements.SingleAssemblyResourceManager _generalResourceManager = null;

        const string UILANGUAGE_EN = "EN";
        const string UILANGUAGE_FR = "FR";
        const string UILANGUAGE_ES = "ES";

        static int Main(string[] args)
        {
            string indentString = "\t";
            int spacesPerTab = 4;
            int maxLineWidth = 999;
            bool trailingCommas = false;
            bool spaceAfterExpandedComma = false;
            bool expandBetweenConditions = true;
            bool expandBooleanExpressions = true;
            bool expandCaseStatements = true;
            bool expandCommaLists = true;
            bool breakJoinOnSections = false;
            bool uppercaseKeywords = true;
            bool standardizeKeywords = true;

            bool allowParsingErrors = false;
            bool showUsage = false;
            List<string> extensions = new List<string>();
            bool backups = true;
            bool recursiveSearch = false;
            string outputFileOrFolder = null;
            string uiLangCode = null;

            OptionSet p = new OptionSet()
              .Add("is|indentString=", delegate(string v) { indentString = v; })
              .Add("st|spacesPerTab=", delegate(string v) { spacesPerTab = int.Parse(v); })
              .Add("mw|maxLineWidth=", delegate(string v) { maxLineWidth = int.Parse(v); })
              .Add("tc|trailingCommas", delegate(string v) { trailingCommas = v != null; })
              .Add("sac|spaceAfterExpandedComma", delegate(string v) { spaceAfterExpandedComma = v != null; })
              .Add("ebc|expandBetweenConditions", delegate(string v) { expandBetweenConditions = v != null; })
              .Add("ebe|expandBooleanExpressions", delegate(string v) { expandBooleanExpressions = v != null; })
              .Add("ecs|expandCaseStatements", delegate(string v) { expandCaseStatements = v != null; })
              .Add("ecl|expandCommaLists", delegate(string v) { expandCommaLists = v != null; })
              .Add("bjo|breakJoinOnSections", delegate(string v) { breakJoinOnSections = v != null; })
              .Add("uk|uppercaseKeywords", delegate(string v) { uppercaseKeywords = v != null; })
              .Add("sk|standardizeKeywords", delegate(string v) { standardizeKeywords = v != null; })
              .Add("ae|allowParsingErrors", delegate(string v) { allowParsingErrors = v != null; })
              .Add("e|extensions=", delegate(string v) { extensions.Add((v.StartsWith(".") ? "" : ".") + v); })
              .Add("r|recursive", delegate(string v) { recursiveSearch = v != null; })
              .Add("b|backups", delegate(string v) { backups = v != null; })
              .Add("o|outputFileOrFolder=", delegate(string v) { outputFileOrFolder = v; })
              .Add("l|languageCode=", delegate(string v) { uiLangCode = v; })
              .Add("h|?|help", delegate(string v) { showUsage = v != null; })
                  ;

            //first parse the args
            List<string> remainingArgs = p.Parse(args);

            //then switch language if necessary
            if (uiLangCode != null)
            {
                if (!uiLangCode.Equals(UILANGUAGE_EN)
                    && !uiLangCode.Equals(UILANGUAGE_FR)
                    && !uiLangCode.Equals(UILANGUAGE_ES)
                    )
                {
                    showUsage = true;
                    //get the resource manager with default language, before displaying error.
                    _generalResourceManager = new FrameworkClassReplacements.SingleAssemblyResourceManager("GeneralLanguageContent", Assembly.GetExecutingAssembly(), typeof(Program));
                    Console.WriteLine(_generalResourceManager.GetString("UnrecognizedLanguageErrorMessage"));
                }
                else
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(uiLangCode);
                    _generalResourceManager = new FrameworkClassReplacements.SingleAssemblyResourceManager("GeneralLanguageContent", Assembly.GetExecutingAssembly(), typeof(Program));
                    //get the resource manager AFTER setting language as requested.
                }
            }
            else
            {
                _generalResourceManager = new FrameworkClassReplacements.SingleAssemblyResourceManager("GeneralLanguageContent", Assembly.GetExecutingAssembly(), typeof(Program));
            }<commit_msg>Cmdline utility language casing sensitivity bug<commit_after>﻿/*
Poor Man's T-SQL Formatter - a small free Transact-SQL formatting 
library for .Net 2.0, written in C#. 
Copyright (C) 2011 <NAME>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
using NDesk.Options;

namespace PoorMansTSqlFormatterCmdLine
{
    class Program
    {
        private static FrameworkClassReplacements.SingleAssemblyResourceManager _generalResourceManager = null;

        const string UILANGUAGE_EN = "EN";
        const string UILANGUAGE_FR = "FR";
        const string UILANGUAGE_ES = "ES";

        static int Main(string[] args)
        {
            string indentString = "\t";
            int spacesPerTab = 4;
            int maxLineWidth = 999;
            bool trailingCommas = false;
            bool spaceAfterExpandedComma = false;
            bool expandBetweenConditions = true;
            bool expandBooleanExpressions = true;
            bool expandCaseStatements = true;
            bool expandCommaLists = true;
            bool breakJoinOnSections = false;
            bool uppercaseKeywords = true;
            bool standardizeKeywords = true;

            bool allowParsingErrors = false;
            bool showUsage = false;
            List<string> extensions = new List<string>();
            bool backups = true;
            bool recursiveSearch = false;
            string outputFileOrFolder = null;
            string uiLangCode = null;

            OptionSet p = new OptionSet()
              .Add("is|indentString=", delegate(string v) { indentString = v; })
              .Add("st|spacesPerTab=", delegate(string v) { spacesPerTab = int.Parse(v); })
              .Add("mw|maxLineWidth=", delegate(string v) { maxLineWidth = int.Parse(v); })
              .Add("tc|trailingCommas", delegate(string v) { trailingCommas = v != null; })
              .Add("sac|spaceAfterExpandedComma", delegate(string v) { spaceAfterExpandedComma = v != null; })
              .Add("ebc|expandBetweenConditions", delegate(string v) { expandBetweenConditions = v != null; })
              .Add("ebe|expandBooleanExpressions", delegate(string v) { expandBooleanExpressions = v != null; })
              .Add("ecs|expandCaseStatements", delegate(string v) { expandCaseStatements = v != null; })
              .Add("ecl|expandCommaLists", delegate(string v) { expandCommaLists = v != null; })
              .Add("bjo|breakJoinOnSections", delegate(string v) { breakJoinOnSections = v != null; })
              .Add("uk|uppercaseKeywords", delegate(string v) { uppercaseKeywords = v != null; })
              .Add("sk|standardizeKeywords", delegate(string v) { standardizeKeywords = v != null; })
              .Add("ae|allowParsingErrors", delegate(string v) { allowParsingErrors = v != null; })
              .Add("e|extensions=", delegate(string v) { extensions.Add((v.StartsWith(".") ? "" : ".") + v); })
              .Add("r|recursive", delegate(string v) { recursiveSearch = v != null; })
              .Add("b|backups", delegate(string v) { backups = v != null; })
              .Add("o|outputFileOrFolder=", delegate(string v) { outputFileOrFolder = v; })
              .Add("l|languageCode=", delegate(string v) { uiLangCode = v; })
              .Add("h|?|help", delegate(string v) { showUsage = v != null; })
                  ;

            //first parse the args
            List<string> remainingArgs = p.Parse(args);

            //then switch language if necessary
            if (uiLangCode != null)
            {
                uiLangCode = uiLangCode.ToUpper(System.Globalization.CultureInfo.InvariantCulture);
                if (!uiLangCode.Equals(UILANGUAGE_EN)
                    && !uiLangCode.Equals(UILANGUAGE_FR)
                    && !uiLangCode.Equals(UILANGUAGE_ES)
                    )
                {
                    showUsage = true;
                    //get the resource manager with default language, before displaying error.
                    _generalResourceManager = new FrameworkClassReplacements.SingleAssemblyResourceManager("GeneralLanguageContent", Assembly.GetExecutingAssembly(), typeof(Program));
                    Console.WriteLine(_generalResourceManager.GetString("UnrecognizedLanguageErrorMessage"));
                }
                else
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(uiLangCode);
                    _generalResourceManager = new FrameworkClassReplacements.SingleAssemblyResourceManager("GeneralLanguageContent", Assembly.GetExecutingAssembly(), typeof(Program));
                    //get the resource manager AFTER setting language as requested.
                }
            }
            else
            {
                _generalResourceManager = new FrameworkClassReplacements.SingleAssemblyResourceManager("GeneralLanguageContent", Assembly.GetExecutingAssembly(), typeof(Program));
            }
{'fraction_non_alphanumeric': 0.09812332439678284, 'fraction_numerical': 0.001966041108132261, 'mean_word_length': 2.4465660609793654, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2219164', 'n_tokens_mistral': 2908, 'n_tokens_neox': 2786, 'n_words': 789}