             case .success(let info): print(info as! String)
             case .fail(let error): print(error)
             }
-        case "release":
-            pod_trunk_push()
-        case "doc":
-            doc_update()
-        default:
-            let version: String = arguments[1]
-            let versionComponents: [String] = version.components(separatedBy: ".")
-            for number in versionComponents {
-                if Int(number) == nil || versionComponents.count != 3 {
-                    fatalError("version: \(version) invalid.")
-                }
-            }
-            switch build() {
-            case .success(let info): print(info as! String)
-            case .fail(let error):
-                print(error)
-                return
-            }
-            switch generate_podspec(version: version) {
-            case .success(let info): print(info as! String)
-            case .fail(let error):
-                print(error)
-                return
-            }
-            switch git_commit_push(version: version) {
-            case .success(let info): print(info as! String)
-            case .fail(let error):
-                print(error)
-                return
-            }
+        case "release": pod_trunk_push()
+        case "doc": doc_update()
+        default: print("❌ error arguments.")
+        }
+    } else {
+        switch current_version() {
+        case .success(let info):
+            let currentVersion: String = info as! String
+            print("current version: \(currentVersion)\n")
+            print("if you want to release with new version, please input version: \n")
+            let newVersion: String = readLine()!
+            switch validate_version(version: newVersion) {
+            case .success(_):
+                switch build() {
+                case .success(let info): print(info as! String)
+                case .fail(let error):
+                    print(error)
+                    return
+                }
+                switch generate_podspec(version: newVersion) {
+                case .success(let info): print(info as! String)
+                case .fail(let error):
+                    print(error)
+                    return
+                }
+                switch git_commit_push(version: newVersion) {
+                case .success(let info): print(info as! String)
+                case .fail(let error):
+                    print(error)
+                    return
+                }
+            case .fail(let error): print(error)
+            }
+        case .fail(let error): print(error)
         }
     }
 }

    
    let tempHeadersFolder: String = "all_public_header_files_tmp/"
    let tempOutputFolder: String = "html/"
    guard !FileManager.default.fileExists(atPath: tempHeadersFolder), !FileManager.default.fileExists(atPath: tempOutputFolder) else {
        print("name conflicts when create folder '\(tempHeadersFolder)'")
        return
    }
    
    let apiDocFolder: String = "../api-docs/api/iOS"
    var isDirectory: ObjCBool = true
    guard FileManager.default.fileExists(atPath: apiDocFolder, isDirectory: &isDirectory), isDirectory.boolValue == true else {
        print("not found iOS doc folder path '\(apiDocFolder)', see https://github.com/leancloud/api-docs")
        return
    }
    
    do {
        let version: String = (try String(contentsOfFile: "AVOS/AVOSCloud/UserAgent.h", encoding: .utf8)).replacingOccurrences(of: "#define SDK_VERSION @\"v", with: "").replacingOccurrences(of: "\"", with: "").trimmingCharacters(in: .whitespacesAndNewlines)
        let versionComponents: [String] = version.components(separatedBy: ".")
        for number in versionComponents {
            if Int(number) == nil || versionComponents.count != 3 {
                fatalError("version: \(version) invalid.")
            }
        }
        
        switch bash(command: "ruby", arguments: ["generate_podspec.rb", "public_header_files"]) {
        case .success(let info):
            try FileManager.default.createDirectory(atPath: tempHeadersFolder, withIntermediateDirectories: true, attributes: nil)
            let filePaths: [String] = (info as! String).components(separatedBy: .newlines)
                .map { $0.trimmingCharacters(in: .whitespaces) }
                .filter { !$0.isEmpty }
            for item in filePaths {
                try FileManager.default.copyItem(atPath: item, toPath: "\(tempHeadersFolder)\(item.components(separatedBy: "/").last!)")
            }
        case .fail(let error):
            print(error)
            return
        }
        
        switch bash(command: "appledoc", arguments:[
            "--create-html",
            "--project-version", version,
            "--output", "./",
            "--company-id", "LeanCloud",
            "--project-company", "LeanCloud, Inc.",
            "--project-name", "LeanCloud Objective-C SDK",
            "--keep-undocumented-objects",
            "--keep-undocumented-members",
            "--no-install-docset",
            "--no-create-docset",
            tempHeadersFolder]
        ){
        case .success(let info):
            print(info as! String)
        case .fail(let error):
            print(error)
        }
        try FileManager.default.removeItem(atPath: apiDocFolder)
        try FileManager.default.removeItem(atPath: tempHeadersFolder)
        try FileManager.default.moveItem(atPath: tempOutputFolder, toPath: apiDocFolder)
    } catch {
        print(error)
    }
}

func main () {
    let arguments = CommandLine.arguments
    if arguments.count < 2 {
        print("❌ error arguments.")
        return
    } else {
        switch arguments[1] {
        case "build":
            switch build() {

    return build_result
}

func validate_version(version: String) -> Result {
    
    let versionComponents: [String] = version.components(separatedBy: ".")
    guard versionComponents.count == 3 else {
        return .fail("invalid version: \(version)")
    }
    for number in versionComponents {
        if Int(number) == nil {
            return .fail("invalid version: \(version)")
        }
    }
    return .success(version)
}

func current_version() -> Result {
    do {
        let filePath: String = "AVOS/AVOSCloud/UserAgent.h"
        let version: String = (try String(contentsOfFile: filePath, encoding: .utf8)).replacingOccurrences(of: "#define SDK_VERSION @\"v", with: "").replacingOccurrences(of: "\"", with: "").trimmingCharacters(in: .whitespacesAndNewlines)
        switch validate_version(version: version) {
        case .success(_): return .success(version)
        case .fail(_): return .fail("invalid version: \(version) in \(filePath)")
        }
    } catch {
        return .fail("\(error)")
    }
}

func generate_podspec(version: String) -> Result {
    
    let check_installed_xcodeproj_result: Result = bash(
