<commit_before>﻿using System;
using System.Threading.Tasks;
using CommandLine;
using Knapcode.ToStorage.Core.AzureBlobStorage;

namespace Knapcode.ToStorage
{
    class Program
    {
        static int Main(string[] args)
        {
            return MainAsync(args).Result;
        }

        public static async Task<int> MainAsync(string[] args)
        {
            // parse options
            var result = Parser.Default.ParseArguments<AzureBlobStorage.Options>(args);
            if (result.Tag == ParserResultType.NotParsed)
            {
                return 1;
            }

            var options = result.MapResult(o => o, e => null);
            if ((options.Account == null && options.Key == null) || options.ConnectionString == null)
            {
                Console.WriteLine("Either a connection string must be specified, or the account and key.");
                return 1;
            }

            // build the implementation models
            var client = new Client();
            var request = new UploadRequest
            {
                Container = options.Container,
                ContentType = options.ContentType,
                PathFormat = options.PathFormat,
                UpdateLatest = options.UpdateLatest,
                Stream = Console.OpenStandardInput(),
                Trace = Console.Out
            };

            // upload
            if (options.ConnectionString != null)
            {
                await client.UploadAsync(options.ConnectionString, request).ConfigureAwait(false);
            }
            else
            {
                await client.UploadAsync(options.Account, options.Key, request).ConfigureAwait(false);
            }
            
            return 0;
        }
    }
}<commit_msg>Close stdin after we are done with it<commit_after>﻿using System;
using System.Threading.Tasks;
using CommandLine;
using Knapcode.ToStorage.Core.AzureBlobStorage;

namespace Knapcode.ToStorage
{
    class Program
    {
        static int Main(string[] args)
        {
            return MainAsync(args).Result;
        }

        public static async Task<int> MainAsync(string[] args)
        {
            // parse options
            var result = Parser.Default.ParseArguments<AzureBlobStorage.Options>(args);
            if (result.Tag == ParserResultType.NotParsed)
            {
                return 1;
            }

            var options = result.MapResult(o => o, e => null);
            if ((options.Account == null && options.Key == null) || options.ConnectionString == null)
            {
                Console.WriteLine("Either a connection string must be specified, or the account and key.");
                return 1;
            }

            // build the implementation models
            var client = new Client();
            using (var stdin = Console.OpenStandardInput())
            {
                var request = new UploadRequest
                {
                    Container = options.Container,
                    ContentType = options.ContentType,
                    PathFormat = options.PathFormat,
                    UpdateLatest = options.UpdateLatest,
                    Stream = stdin,
                    Trace = Console.Out
                };

                // upload
                if (options.ConnectionString != null)
                {
                    await client.UploadAsync(options.ConnectionString, request).ConfigureAwait(false);
                }
                else
                {
                    await client.UploadAsync(options.Account, options.Key, request).ConfigureAwait(false);
                }
            }

            return 0;
        }
    }
}
{'fraction_non_alphanumeric': 0.08499730167296277, 'fraction_numerical': 0.0016189962223421479, 'mean_word_length': 1.4340118187787263, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '1735917', 'n_tokens_mistral': 891, 'n_tokens_neox': 846, 'n_words': 209}