Showing posts with label Command-line argument parsing. Show all posts
Showing posts with label Command-line argument parsing. Show all posts

Tuesday, May 23, 2017

Swift: Command Line Argument Parsing

Command:

$ cat ./Desktop/Arguments\ Test/Arguments\ Test/main.swift


Result:

import Foundation

var count = 0

for argument in CommandLine.arguments {
    print("Arg[\(count)]: \(argument)")
    count += 1
}


Command:

$ ./Library/Developer/Xcode/DerivedData/Arguments_Test-ffnafkbrsdftjxdawcsyrdhlfnvu/Build/Products/Debug/Arguments\ Test first second third


Result:

Arg[0]: ./Library/Developer/Xcode/DerivedData/Arguments_Test-ffnafkbrsdftjxdawcsyrdhlfnvu/Build/Products/Debug/Arguments Test
Arg[1]: first
Arg[2]: second
Arg[3]: third

Wednesday, October 26, 2016

CLISP: Command-line Argument Parsing Example

Command:

$ cat command_line_args_parsing.lisp


Result:

(print *args*)


Command:

$ clisp command_line_args_parsing.lisp Hello World 123


Result:

("Hello" "World" "123")