<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using StructureMap;
using Sep.Git.Tfs.Commands;
using Sep.Git.Tfs.Core;
using Sep.Git.Tfs.Core.TfsInterop;
using Sep.Git.Tfs.Util;

namespace Sep.Git.Tfs
{
    public class GitTfs
    {
        private IGitTfsVersionProvider _gitTfsVersionProvider;
        private ITfsHelper tfsHelper;
        private GitTfsCommandFactory commandFactory;
        private readonly IHelpHelper _help;
        private readonly IContainer _container;
        private readonly GitTfsCommandRunner _runner;
        private readonly Globals _globals;

        public GitTfs(ITfsHelper tfsHelper, GitTfsCommandFactory commandFactory, IHelpHelper help, IContainer container, IGitTfsVersionProvider gitTfsVersionProvider, GitTfsCommandRunner runner, Globals globals)
        {
            this.tfsHelper = tfsHelper;
            this.commandFactory = commandFactory;
            _help = help;
            _container = container;
            _gitTfsVersionProvider = gitTfsVersionProvider;
            _runner = runner;
            _globals = globals;
        }

        public int Run(IList<string> args)
        {
            InitializeGlobals();
            var command = ExtractCommand(args);
            if(RequiresValidGitRepository(command)) AssertValidGitRepository();
            var unparsedArgs = ParseOptions(command, args);
            return Main(command, unparsedArgs);
        }

        public int Main(GitTfsCommand command, IList<string> unparsedArgs)
        {
            Trace.WriteLine(_gitTfsVersionProvider.GetVersionString());
            if(_globals.ShowHelp)
            {
                return _help.ShowHelp(command);
            }
            else if(_globals.ShowVersion)
            {
                _container.GetInstance<TextWriter>().WriteLine(_gitTfsVersionProvider.GetVersionString());
                return GitTfsExitCodes.OK;
            }
            else
            {
                return _runner.Run(command, unparsedArgs);
            }
        }
<commit_msg>Explicitly clean up the things.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using StructureMap;
using Sep.Git.Tfs.Commands;
using Sep.Git.Tfs.Core;
using Sep.Git.Tfs.Core.TfsInterop;
using Sep.Git.Tfs.Util;

namespace Sep.Git.Tfs
{
    public class GitTfs
    {
        private IGitTfsVersionProvider _gitTfsVersionProvider;
        private ITfsHelper tfsHelper;
        private GitTfsCommandFactory commandFactory;
        private readonly IHelpHelper _help;
        private readonly IContainer _container;
        private readonly GitTfsCommandRunner _runner;
        private readonly Globals _globals;

        public GitTfs(ITfsHelper tfsHelper, GitTfsCommandFactory commandFactory, IHelpHelper help, IContainer container, IGitTfsVersionProvider gitTfsVersionProvider, GitTfsCommandRunner runner, Globals globals)
        {
            this.tfsHelper = tfsHelper;
            this.commandFactory = commandFactory;
            _help = help;
            _container = container;
            _gitTfsVersionProvider = gitTfsVersionProvider;
            _runner = runner;
            _globals = globals;
        }

        public int Run(IList<string> args)
        {
            InitializeGlobals();
            var command = ExtractCommand(args);
            if(RequiresValidGitRepository(command)) AssertValidGitRepository();
            var unparsedArgs = ParseOptions(command, args);
            return Main(command, unparsedArgs);
        }

        public int Main(GitTfsCommand command, IList<string> unparsedArgs)
        {
            Trace.WriteLine(_gitTfsVersionProvider.GetVersionString());
            if(_globals.ShowHelp)
            {
                return _help.ShowHelp(command);
            }
            else if(_globals.ShowVersion)
            {
                _container.GetInstance<TextWriter>().WriteLine(_gitTfsVersionProvider.GetVersionString());
                return GitTfsExitCodes.OK;
            }
            else
            {
                try
                {
                    return _runner.Run(command, unparsedArgs);
                }
                finally
                {
                    _container.GetInstance<Janitor>().Dispose();
                }
            }
        }

{'fraction_non_alphanumeric': 0.06982432732933067, 'fraction_numerical': 0.0, 'mean_word_length': 2.1698379140239608, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '3463474', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1168, 'n_words': 241}