<commit_before>﻿namespace SIM.Client
{
  using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Linq;
  using CommandLine;
  using Newtonsoft.Json;
  using SIM.Client.Commands;
  using SIM.Client.Serialization;
  using SIM.Core;
  using SIM.Core.Common;
  using Sitecore.Diagnostics.Base;
  using Sitecore.Diagnostics.Base.Annotations;

  public static class Program
  {
    public static void Main([NotNull] string[] args)
    {
      Assert.ArgumentNotNull(args, "args");

      CoreApp.InitializeLogging();

      CoreApp.LogMainInfo();

      Analytics.Start();

      var filteredArgs = args.ToList();
      var query = GetQueryAndFilterArgs(filteredArgs);
      var wait = GetWaitAndFilterArgs(filteredArgs);

      var parser = new Parser(with => with.HelpWriter = Console.Error);
      Assert.IsNotNull(parser, "parser");

      var options = new MainCommandGroup();
      if (!parser.ParseArguments(filteredArgs.ToArray(), options, delegate { }))
      {
        Console.WriteLine("\r\n  --query\t      When specified, allows returning only part of any command's output");
        Console.WriteLine("\r\n  --wait\t       When specified, waits for keyboard input before terminating");
        Environment.Exit(Parser.DefaultExitCodeFail);
      }

      var result = options.SelectedCommand.Execute() as object;

      result = QueryResult(result, query);
      if (result == null)
      {
        return;
      }

      var serializer = new JsonSerializer
      {
        NullValueHandling = NullValueHandling.Ignore,
        Formatting = Formatting.Indented,        
      };

      serializer.Converters.Add(new DirectoryInfoConverter());

      var writer = Console.Out;
      serializer.Serialize(writer, result);
<commit_msg>Code cleanup<commit_after>﻿namespace SIM.Client
{
  using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Linq;
  using CommandLine;
  using Newtonsoft.Json;
  using SIM.Client.Commands;
  using SIM.Client.Serialization;
  using SIM.Core;
  using SIM.Core.Common;
  using Sitecore.Diagnostics.Base;
  using Sitecore.Diagnostics.Base.Annotations;

  public static class Program
  {
    public static void Main([NotNull] string[] args)
    {
      Assert.ArgumentNotNull(args, "args");

      CoreApp.InitializeLogging();

      CoreApp.LogMainInfo();

      Analytics.Start();

      var filteredArgs = args.ToList();
      var query = GetQueryAndFilterArgs(filteredArgs);
      var wait = GetWaitAndFilterArgs(filteredArgs);

      var parser = new Parser(with => with.HelpWriter = Console.Error);
      Assert.IsNotNull(parser, "parser");

      var options = new MainCommandGroup();
      if (!parser.ParseArguments(filteredArgs.ToArray(), options, delegate { }))
      {
        Console.WriteLine("\r\n  --query\t      When specified, allows returning only part of any command's output");
        Console.WriteLine("\r\n  --wait\t       When specified, waits for keyboard input before terminating");
        Environment.Exit(Parser.DefaultExitCodeFail);
      }

      var result = options.SelectedCommand.Execute();

      result = QueryResult(result, query);
      if (result == null)
      {
        return;
      }

      var serializer = new JsonSerializer
      {
        NullValueHandling = NullValueHandling.Ignore,
        Formatting = Formatting.Indented,        
      };

      serializer.Converters.Add(new DirectoryInfoConverter());

      var writer = Console.Out;
      serializer.Serialize(writer, result);

{'fraction_non_alphanumeric': 0.10330228619813717, 'fraction_numerical': 0.0, 'mean_word_length': 2.920353982300885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '741510', 'n_tokens_mistral': 991, 'n_tokens_neox': 956, 'n_words': 231}