Guaka

Smart and beautiful POSIX compliant CLI framework for Swift.

Create modern and familiar CLI apps in the vein of widely used projects such as: Git, Docker, Kubernetes, OpenShift, Hugo and more!

Inspired by the amazing Cobra package from the Golang's ecosystem.

Features
  • Simple and idiomatic APINo rocket science here! Full modern CLI apps in a few lines of code.
  • Easy to useWith the Guaka generator you can bootstrap your own CLI in matter of minutes.
  • Lightweight and portableNo libFoundation and friends, can be statically linked.
  • POSIX compliantShort and long flags, flags can appear anywhere.
  • Safe and crash free100% safe code as in: unsafe code.
  • TestedClose to 100% test coverage and 100% dog fooded (the Guaka CLI app is written in, yes you guessed, Guaka ;).
  • DocumentedLots of docs and samples.
Full feature set
Getting Started

Using the Guaka Generator

The easiest way to use Guaka is by using the Guaka Generator.

Installing on macOS

You can install the Guaka generator CLI application in macOS with homebrew:

brew install oarrabi/tap/guaka

Alternatively, you can install it using the installer script:

curl https://raw.githubusercontent.com/oarrabi/Guaka-Generator/master/scripts/install.sh -sSf | bash

Lastly you can install it by copying the binary from github and placing it in your path.
Go to https://github.com/oarrabi/Guaka-Generator/releases

Installing on GNU/Linux

If you are on GNU/Linux you can run the installer script:

curl https://raw.githubusercontent.com/oarrabi/Guaka-Generator/master/scripts/install.sh -sSf | bash

Alternatively, You can install it by copying the binary from github and placing it in your path.
Go to https://github.com/oarrabi/Guaka-Generator/releases



After guaka is installed you should be able to create your first command line application with:

guaka create path/to/place/your/app

This will create a swift package manager project at the specified path.

Read more about using the guaka generator.

Manual installation

Alternatively, you can using Guaka as a swift package manager dependency.

Start by creating a swift package manager (SPM) executable project:

swift package init --type executable

Add guaka to the dependencies by editting Package.swift:

import PackageDescription

let package = Package(name: "YourPackage",
  dependencies: [
    .Package(url: "https://github.com/oarrabi/Guaka.git", majorVersion: 0),
  ]
)

Fetch the project dependencies:

swift package fetch

Create a command. Go to main.swift and paste the following snippet:

import Guaka

let command = Command(usage: "hello") { _, args in
  print("You passed \(args) to your Guaka app!")
}

command.execute()

Build the project

swift build

Congratulations, you just created your first Guaka application!

Give it a run with:

> ./.build/debug/{projectName} "Hello CLI World!"
Read more about creating a guaka swift package manager command line app.