// // main.swift // Swift Command Line // // Created by User on 10/4/22. // Thanks to ... // https://stackoverflow.com/questions/27046728/how-do-you-use-posix-spawn-to-replace-the-deprecated-system-to-launch-opendiff import Foundation func system(_ command: String) { var args = command.components(separatedBy: " ") let path = args.first args.remove(at: 0) let task = Process() task.launchPath = path task.arguments = args task.launch() task.waitUntilExit() } var msg = "" var i = 2 if CommandLine.arguments.count <= 1 { print("Hello, World!") } else { msg = CommandLine.arguments[1] while i < CommandLine.arguments.count { msg += " " + CommandLine.arguments[i] i += 1 } print(msg) } system("/usr/bin/python /Applications/MAMP/htdocs/tkinter_filebrowser_test.py")