<commit_before>//
//  Command.swift
//  Carthage
//
//  Created by <NAME> on 2014-10-10.
//  Copyright (c) 2014 Carthage. All rights reserved.
//

import CarthageKit
import Foundation
import ReactiveCocoa

protocol CommandType {
	var verb: String { get }

	init()

	func run(arguments: [String]) -> ColdSignal<()>
}

protocol OptionsType {
	class func parse(args: [String]) -> ColdSignal<Self>
}

protocol ArgumentType {
	class func fromString(string: String) -> Self?
}

struct Option<T> {
	let key: String
	let defaultValue: T
	let usage: String
}

func option<T: ArgumentType>(key: String, defaultValue: T, usage: String) -> Option<T> {
	return Option(key: key, defaultValue: defaultValue, usage: usage)
}

func option<T: ArgumentType>(key: String, usage: String) -> Option<T?> {
	return Option(key: key, defaultValue: nil, usage: usage)
}

extension Bool: ArgumentType {
	static func fromString(string: String) -> Bool? {
		return (string as NSString).boolValue
	}
}

extension Int: ArgumentType {
	static func fromString(string: String) -> Int? {
		return string.toInt()
	}
}
<commit_msg>Remove Bool: ArgumentType for now<commit_after>//
//  Command.swift
//  Carthage
//
//  Created by <NAME> on 2014-10-10.
//  Copyright (c) 2014 Carthage. All rights reserved.
//

import CarthageKit
import Foundation
import ReactiveCocoa

protocol CommandType {
	var verb: String { get }

	init()

	func run(arguments: [String]) -> ColdSignal<()>
}

protocol OptionsType {
	class func parse(args: [String]) -> ColdSignal<Self>
}

protocol ArgumentType {
	class func fromString(string: String) -> Self?
}

struct Option<T> {
	let key: String
	let defaultValue: T
	let usage: String
}

func option<T: ArgumentType>(key: String, defaultValue: T, usage: String) -> Option<T> {
	return Option(key: key, defaultValue: defaultValue, usage: usage)
}

func option<T: ArgumentType>(key: String, usage: String) -> Option<T?> {
	return Option(key: key, defaultValue: nil, usage: usage)
}

extension Int: ArgumentType {
	static func fromString(string: String) -> Int? {
		return string.toInt()
	}
}

{'fraction_non_alphanumeric': 0.1323387872954764, 'fraction_numerical': 0.011549566891241578, 'mean_word_length': 4.290076335877862, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 32, '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': '3181223', 'n_tokens_mistral': 712, 'n_tokens_neox': 678, 'n_words': 210}