 
 // MARK: - Extensions
 
-extension Pipe {
-    var output: String? {
-        let outputData = fileHandleForReading.readDataToEndOfFile()
-        return String(data: outputData, encoding: .utf8)
+extension Process {
+    @discardableResult func launchBash(withCommand command: String) -> String? {
+        launchPath = "/bin/bash"
+        arguments = ["-c", command]
+        
+        let pipe = Pipe()
+        standardOutput = pipe
+        
+        // Silent errors by assigning a dummy pipe to the error output
+        standardError = Pipe()
+        
+        launch()
+        waitUntilExit()
+        
+        let outputData = pipe.fileHandleForReading.readDataToEndOfFile()
+        return String(data: outputData, encoding: .utf8)?.nonEmpty
+    }
+    
+    func gitConfigValue(forKey key: String) -> String? {
+        return launchBash(withCommand: "git config --global --get \(key)")?.trimmingCharacters(in: .whitespacesAndNewlines)
     }
 }
 


let arguments = Arguments(commandLineArguments: CommandLine.arguments)
let destination = arguments.destination ?? askForDestination()
let projectName = arguments.projectName ?? askForRequiredInfo(question: "📛  What's the name of your project?", errorMessage: "Project name cannot be empty")
let authorName = arguments.authorName ?? askForRequiredInfo(question: "👶  What's your name?", errorMessage: "Your name cannot be empty")
let authorEmail = arguments.authorEmail ?? askForOptionalInfo(question: "📫  What's your email address (for Podspec)?")
let gitHubURL = arguments.githubURL ?? askForOptionalInfo(question: "🌍  Any GitHub URL that you'll be hosting this project at (for Podspec)?")
let organizationName = arguments.organizationName ?? askForOptionalInfo(question: "🏢  What's your organization name?")

print("---------------------------------------------------------------------")

        }
        
        return self
    }
    
    func withoutSuffix(_ suffix: String) -> String {
        guard hasSuffix(suffix) else {
            return self
        }
        
        let startIndex = index(endIndex, offsetBy: -suffix.characters.count)
        return replacingCharacters(in: startIndex..<endIndex, with: "")
    }
}

