<commit_before>using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Codex.Analysis;
using Codex.Analysis.External;
using Codex.Analysis.Files;
using Codex.Analysis.FileSystems;
using Codex.Analysis.Managed;
using Codex.Analysis.Projects;
using Codex.Analysis.Xml;
using Codex.Import;
using Codex.Logging;
using Codex.ObjectModel;
using Codex.Storage;
using Mono.Options;

namespace Codex.Application
{
    class Program
    {
        static string elasticSearchServer = "http://localhost:9200";
        static bool finalize = true;
        static bool analysisOnly = false; // Set this to disable uploading to ElasticSearch
        static string repoName;
        static string rootDirectory;
        static string solutionPath;
        static bool interactive = false;
        static bool listIndices = false;
        static List<string> deleteIndices = new List<string>();

        static OptionSet options = new OptionSet
        {
            { "l|list", "List the indices.", n => listIndices = n != null },
            { "d=", "List the indices to delete.", n => deleteIndices.Add(n) },
            { "es|elasticsearch=", "URL of the ElasticSearch server.", n => elasticSearchServer = n },
            { "n|name=", "Name of the repository.", n => repoName = AnalysisServices.GetSafeIndexName(n ?? string.Empty) },
            { "p|path=", "Path to the repo to analyze.", n => rootDirectory = n },
            { "s|solution=", "Optionally, path to the solution to analyze.", n => solutionPath = n },
            { "i|interactive", "Search newly indexed items.", n => interactive = n != null }
        };

        static void Main(string[] args)
        {
            var extras = options.Parse(args);
            if (String.IsNullOrEmpty(rootDirectory)) throw new ArgumentException("Solution path is missing. Use -p to provide it.");
            if (String.IsNullOrEmpty(repoName)) throw new ArgumentException("Repository name is missing. Use -n to provide it.");
            if (String.IsNullOrEmpty(elasticSearchServer)) throw new ArgumentException("Elastic Search server URL is missing. Use -es to provide it.");

            if (listIndices)
            {
                ListIndices();
                return;
            }

            if (deleteIndices.Count != 0)
            {
                DeleteIndices();

                Console.WriteLine("Remaining Indices:");
                ListIndices();
                return;
            }
<commit_msg>Move argument validation to after we handle -l and -d.<commit_after>using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Codex.Analysis;
using Codex.Analysis.External;
using Codex.Analysis.Files;
using Codex.Analysis.FileSystems;
using Codex.Analysis.Managed;
using Codex.Analysis.Projects;
using Codex.Analysis.Xml;
using Codex.Import;
using Codex.Logging;
using Codex.ObjectModel;
using Codex.Storage;
using Mono.Options;

namespace Codex.Application
{
    class Program
    {
        static string elasticSearchServer = "http://localhost:9200";
        static bool finalize = true;
        static bool analysisOnly = false; // Set this to disable uploading to ElasticSearch
        static string repoName;
        static string rootDirectory;
        static string solutionPath;
        static bool interactive = false;
        static bool listIndices = false;
        static List<string> deleteIndices = new List<string>();

        static OptionSet options = new OptionSet
        {
            { "l|list", "List the indices.", n => listIndices = n != null },
            { "d=", "List the indices to delete.", n => deleteIndices.Add(n) },
            { "es|elasticsearch=", "URL of the ElasticSearch server.", n => elasticSearchServer = n },
            { "n|name=", "Name of the repository.", n => repoName = AnalysisServices.GetSafeIndexName(n ?? string.Empty) },
            { "p|path=", "Path to the repo to analyze.", n => rootDirectory = n },
            { "s|solution=", "Optionally, path to the solution to analyze.", n => solutionPath = n },
            { "i|interactive", "Search newly indexed items.", n => interactive = n != null }
        };

        static void Main(string[] args)
        {
            var extras = options.Parse(args);

            Console.WriteLine("Server: " + elasticSearchServer);

            if (listIndices)
            {
                ListIndices();
                return;
            }

            if (deleteIndices.Count != 0)
            {
                DeleteIndices();

                Console.WriteLine("Remaining Indices:");
                ListIndices();
                return;
            }

            if (string.IsNullOrEmpty(rootDirectory)) throw new ArgumentException("Solution path is missing. Use -p to provide it.");
            if (string.IsNullOrEmpty(repoName)) throw new ArgumentException("Repository name is missing. Use -n to provide it.");
            if (string.IsNullOrEmpty(elasticSearchServer)) throw new ArgumentException("Elastic Search server URL is missing. Use -es to provide it.");

{'fraction_non_alphanumeric': 0.10684250764525993, 'fraction_numerical': 0.00191131498470948, 'mean_word_length': 2.460978835978836, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '4698932', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1335, 'n_words': 431}