Skip to content

Instantly share code, notes, and snippets.

@atchoo78
Last active December 29, 2023 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atchoo78/5e4b61fad929ed0a90f215bd1d3d1334 to your computer and use it in GitHub Desktop.
Save atchoo78/5e4b61fad929ed0a90f215bd1d3d1334 to your computer and use it in GitHub Desktop.
Open file name in CLI app passed as -input argument in Swift 5.x
if(CommandLine.arguments.count >= 1) {
for argument in CommandLine.arguments {
if argument.contains("-input") {
let fileInput = CommandLine.arguments.firstIndex(of: "-input")
let fileName = CommandLine.arguments[fileInput! + 1]
// print(fileName)
// do something with fileName here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment