Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Accessing launch arguments and inputs in a command line tool

Accessing launch arguments and inputs in a command line tool

Daily Coding Tip 008

Type Safely's avatar
Type Safely
Dec 26, 2020
∙ Paid
1

Share this post

Type Safely
Type Safely
Accessing launch arguments and inputs in a command line tool
Share
Image by Irenna86 on Pixabay

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")
view raw main.swift hosted with ❤ by GitHub

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.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share