Corazza is a library to create interactive Swift scripts or command line tools. It enables to ask questions on standard output and read answers from standard input.
A simple example Swift script usage can be found in the Example folder.
Asks which kind of turtles is your favourite:
Do you like turtles?
[Y]es or [N]o? (default: Y) > y
Which one is your favourite?
------------------------------------
1 Chelonoidis nigra
2 Dermochelys coriacea
3 Chelydra serpentina
4 Trachemys scripta elegans
------------------------------------
Choose an option > 2
I love Dermochelys coriacea!
Just add import Corazza
to your script
In order to be able to import it, you need to have the Corazza
in the Swift search path. You can achieve this by compiling it yourself or downloading a binary version from a release. You need to invoke Swift with the -F
argument, pointing to the folder where Corazza is stored.
Corazza can be downloaded locally with Carthage.
Just add
github "marcoconti83/Corazza"
to your Cartfile
. After running
carthage update
you would be able to run any swift file with
swift -F Carthage/Build/Mac
The -F
flag can also be included in the shebang line of the script, so that you can just invoke the script directly (e.g. $> do.swift
). This is the approach used in the examples included with this project.
You can download the framework binary from the GitHub latest release