I wanna know how these are different CommandLine ProcessInfo
let elements = CommandLine.arguments
let elements = Processinfo.processinfo.arguments
In my thinking, ProcessInfo’s arguments have all of the Commandline's concept. So there is no differences for dealing with argument.
The code below, using CommandLine.arguments, is for practicing read and write file.
If I put Processinfo.processinfo.arguments at location of CommanLine.arguments. Nothing changed.
static func makeInOutFile() -> (inputFile: String, outputFile: String)? {
    let elements = CommandLine.arguments
    let inputFile: String
    let outputFile: String
    switch elements.count {
    case 2:
        inputFile = elements[1]
        outputFile = Message.ofDefaultJSONFileName.description
        return (inputFile: inputFile, outputFile: outputFile)
    case 3:
        inputFile = elements[1]
        outputFile = elements[2]
        return (inputFile: inputFile, outputFile: outputFile)
    default:
        print (Message.ofFailedProcessingFile)
        return nil
    }
}
                CommandLine is part of the Swift standard library and only provides the command line arguments and the argument count.
ProcessInfo is part of the Foundation framework (not part of the language). While ProcessInfo.arguments does gives you the same results as CommandLine.arguments, there is a lot more to the ProcessInfo class.
While the two arguments are functionally the same, if all you want is the command line arguments, use CommandLine. It's simpler, it doesn't rely on any additional frameworks, and it would be more portable to other Swift runtimes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With