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
for argument in arguments {print(argument)}
var inputString = String()
while inputString != "quit"
inputString = readLine()!
print("You said: \(inputString)")
print("The program has ended")
view raw main.swift hosted with ❤ by GitHub

If you have, you probably won’t.

Get more Daily Coding Tips in your inbox!