Accessing launch arguments and inputs in a command line tool
Daily Coding Tip 008

This is the only attempt I’ve ever made at a command line tool for macOS.
If you’ve never made one before, you might find it useful.
| import Foundation | |
| print("Hello, World!") | |
| var arguments = CommandLine.arguments | |
| print(arguments.count) | |
| for argument in arguments {print(argument)} | |
| var inputString = String() | |
| while inputString != "quit" | |
| { | |
| inputString = readLine()! | |
| print("You said: \(inputString)") | |
| } | |
| print("The program has ended") |
If you have, you probably won’t.
Keep reading with a 7-day free trial
Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

