import Foundation
import SwiftShell
import Regex

let files = [
    "./Sentry.podspec",
    "./docs/sentry-doc-config.json",
    "./Sentry/Info.plist",
    "./Sources/Sentry.swift",
]

let args = CommandLine.arguments

let regex = Regex("[0-9]+\\.[0-9]+\\.[0-9]+")
if regex.match(args[1]) == nil || regex.match(args[2]) == nil {
    exit(errormessage: "version number must bit 0.0.0 format" )
}

let fromVersion = args[1]
let toVersion = args[2]
for file in files {
    let readFile = try open(file)
    let contents: String = readFile.read()
    let newContents = contents.replacingOccurrences(of: fromVersion, with: toVersion)
    let overwriteFile = try! open(forWriting: file, overwrite: true)
    overwriteFile.write(newContents)
    overwriteFile.close()
}

import Foundation
import SwiftShell
import Regex

let files = [
    "./Sentry.podspec",
    "./docs/sentry-doc-config.json",
    "./Sentry/Info.plist",
    "./Sources/Sentry.swift",
]

let args = CommandLine.arguments

let regex = Regex("[0-9]+\\.[0-9]+\\.[0-9]+")
if regex.match(args[1]) == nil || regex.match(args[2]) == nil {
    exit(errormessage: "version number must bit 0.0.0 format" )
}

let fromVersion = args[1]
let toVersion = args[2]
for file in files {
    //let fileContents = try! String(contentsOfFile: file, encoding: .utf8)
    //print("\(fileContents.replacingOccurrences(of: " ", with: "+"))")

    let readFile = try open(file)
    let contents: String = readFile.read()
    let newContents = contents.replacingOccurrences(of: fromVersion, with: toVersion)
    let overwriteFile = try! open(forWriting: file, overwrite: true)
    overwriteFile.write(newContents)
    overwriteFile.close()
}



--- 
+++ 
@@ -19,9 +19,6 @@
 let fromVersion = args[1]
 let toVersion = args[2]
 for file in files {
-    //let fileContents = try! String(contentsOfFile: file, encoding: .utf8)
-    //print("\(fileContents.replacingOccurrences(of: " ", with: "+"))")
-
     let readFile = try open(file)
     let contents: String = readFile.read()
     let newContents = contents.replacingOccurrences(of: fromVersion, with: toVersion)
@@ -29,5 +26,3 @@
     overwriteFile.write(newContents)
     overwriteFile.close()
 }
-
-
Remove unused code in utils
