Last active
December 29, 2023 14:32
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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