<commit_before>﻿using System.IO;
using System.Linq;

namespace AppHarbor.Commands
{
	[CommandHelp("Create an application", "[NAME]", "create")]
	public class CreateAppCommand : Command
	{
		private readonly IAppHarborClient _appHarborClient;
		private readonly IApplicationConfiguration _applicationConfiguration;
		private readonly TextWriter _textWriter;

		public CreateAppCommand(IAppHarborClient appHarborClient, IApplicationConfiguration applicationConfiguration, TextWriter textWriter)
		{
			_appHarborClient = appHarborClient;
			_applicationConfiguration = applicationConfiguration;
			_textWriter = textWriter;
		}

		public override void Execute(string[] arguments)
		{
			if (arguments.Length == 0)
			{
				throw new CommandException("An application name must be provided to create an application");
			}

			var result = _appHarborClient.CreateApplication(arguments.First(), arguments.Skip(1).FirstOrDefault());

			_textWriter.WriteLine("Created application \"{0}\" | URL: https://{0}.apphb.com", result.Id);
			_textWriter.WriteLine("");

			try
			{
				_textWriter.WriteLine("This directory is already configured to track application \"{0}\".",
					_applicationConfiguration.GetApplicationId());
			}
			catch (ApplicationConfigurationException)
			{
				_applicationConfiguration.SetupApplication(result.Id, _appHarborClient.GetUser());
			}
		}
	}
}
<commit_msg>Parse region as optional parameter<commit_after>﻿using System.IO;
using System.Linq;

namespace AppHarbor.Commands
{
	[CommandHelp("Create an application", "[NAME]", "create")]
	public class CreateAppCommand : Command
	{
		private readonly IAppHarborClient _appHarborClient;
		private readonly IApplicationConfiguration _applicationConfiguration;
		private readonly TextWriter _textWriter;

		private string _region;

		public CreateAppCommand(IAppHarborClient appHarborClient, IApplicationConfiguration applicationConfiguration, TextWriter textWriter)
		{
			_appHarborClient = appHarborClient;
			_applicationConfiguration = applicationConfiguration;
			_textWriter = textWriter;

			OptionSet.Add("r|region=", "Optionally specify a region", x => _region = x);
		}

		public override void Execute(string[] arguments)
		{
			if (arguments.Length == 0)
			{
				throw new CommandException("An application name must be provided to create an application");
			}

			var result = _appHarborClient.CreateApplication(arguments.First(), _region);

			_textWriter.WriteLine("Created application \"{0}\" | URL: https://{0}.apphb.com", result.Id);
			_textWriter.WriteLine("");

			try
			{
				_textWriter.WriteLine("This directory is already configured to track application \"{0}\".",
					_applicationConfiguration.GetApplicationId());
			}
			catch (ApplicationConfigurationException)
			{
				_applicationConfiguration.SetupApplication(result.Id, _appHarborClient.GetUser());
			}
		}
	}
}

{'fraction_non_alphanumeric': 0.09895470383275261, 'fraction_numerical': 0.0031358885017421603, 'mean_word_length': 5.134615384615385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '7578066', 'n_tokens_mistral': 878, 'n_tokens_neox': 760, 'n_words': 187}