<commit_before>//
//  main.swift
//  R.swift
//
//  Created by <NAME> on 11-12-14.
//  From: https://github.com/mac-cain13/R.swift
//  License: MIT License
//

import Foundation
import Commander
import RswiftCore


// Argument convertibles
extension AccessLevel : ArgumentConvertible, CustomStringConvertible {
  public init(parser: ArgumentParser) throws {
    guard let value = parser.shift() else { throw ArgumentError.missingValue(argument: nil) }
    guard let level = AccessLevel(rawValue: value) else { throw ArgumentError.invalidType(value: value, type: "AccessLevel", argument: nil) }

    self = level
  }

  public var description: String {
    return rawValue
  }
}


extension ProcessInfo {
  func value(from current: String, name: String, key: String) throws -> String {
    if current != key { return current }
    guard let value = self.environment[key] else { throw ArgumentError.missingValue(argument: name) }

    return value
  }
}

// Flags grouped in struct for readability
struct CommanderFlags {
  static let version = Flag("version", description: "Prints version information about this release.")
  static let edge = Flag("edge", description: "Enable stable features that will be in the next major release.")
}

// Default values for non-optional Commander Options
struct EnvironmentKeys {
  static let xcodeproj = "PROJECT_FILE_PATH"
  static let target = "TARGET_NAME"
  static let bundleIdentifier = "PRODUCT_BUNDLE_IDENTIFIER"
  static let productModuleName = "PRODUCT_MODULE_NAME"
  static let buildProductsDir = "BUILT_PRODUCTS_DIR" // "BUILT" is the correct spelling here
  static let developerDir = "DEVELOPER_DIR"
  static let sourceRoot = "SOURCE_ROOT"
  static let sdkRoot = "SDKROOT"
}
<commit_msg>Use SourceTreeFolder for environment keys<commit_after>//
//  main.swift
//  R.swift
//
//  Created by <NAME> on 11-12-14.
//  From: https://github.com/mac-cain13/R.swift
//  License: MIT License
//

import Foundation
import Commander
import RswiftCore
import XcodeEdit


// Argument convertibles
extension AccessLevel : ArgumentConvertible, CustomStringConvertible {
  public init(parser: ArgumentParser) throws {
    guard let value = parser.shift() else { throw ArgumentError.missingValue(argument: nil) }
    guard let level = AccessLevel(rawValue: value) else { throw ArgumentError.invalidType(value: value, type: "AccessLevel", argument: nil) }

    self = level
  }

  public var description: String {
    return rawValue
  }
}


extension ProcessInfo {
  func value(from current: String, name: String, key: String) throws -> String {
    if current != key { return current }
    guard let value = self.environment[key] else { throw ArgumentError.missingValue(argument: name) }

    return value
  }
}

// Flags grouped in struct for readability
struct CommanderFlags {
  static let version = Flag("version", description: "Prints version information about this release.")
  static let edge = Flag("edge", description: "Enable stable features that will be in the next major release.")
}

// Default values for non-optional Commander Options
struct EnvironmentKeys {
  static let xcodeproj = "PROJECT_FILE_PATH"
  static let target = "TARGET_NAME"
  static let bundleIdentifier = "PRODUCT_BUNDLE_IDENTIFIER"
  static let productModuleName = "PRODUCT_MODULE_NAME"
  static let buildProductsDir = SourceTreeFolder.buildProductsDir.rawValue
  static let developerDir = SourceTreeFolder.developerDir.rawValue
  static let sourceRoot = SourceTreeFolder.sourceRoot.rawValue
  static let sdkRoot = SourceTreeFolder.sdkRoot.rawValue
}

{'fraction_non_alphanumeric': 0.08915054667788057, 'fraction_numerical': 0.00448556209700028, 'mean_word_length': 4.262536873156342, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5686452', 'n_tokens_mistral': 1020, 'n_tokens_neox': 986, 'n_words': 332}