lf-araujo / docopt.swift

Friendly fork from docopt.swift, which now works on linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build status docopt.swift is a Swift port of docopt, now Linux compatible.

docopt.swift helps you create most beautiful command-line interfaces easily. This project is a friendly fork of the docopt team original work, but which compiles on Linux and is also Marathon compatible.

I made little changes to the project, forked from @samdeane original PR. A minimally working example looks like:

import Foundation
import Glibc
import Docopt // marathon: /home/luis/Dropbox/Documentos/Coding/Swift/docopt.swift

let doc : String = """
Not a serious example.

Usage:
  calculator_example.py <value> ( ( + | - | * | / ) <value> )...
  calculator_example.py <function> <value> [( , <value> )]...
  calculator_example.py (-h | --help)
  
Examples:
  calculator_example.py 1 + 2 + 3 + 4 + 5
  calculator_example.py 1 + 2 '*' 3 / 4 - 5    # note quotes around '*'
  calculator_example.py sum 10 , 20 , 30 , 40
  
Options:
  -h, --help
"""
var args = CommandLine.arguments
args.remove(at: 0)

print(args)
let result = Docopt.parse(doc, argv: args, help: true, version: "1.0")
print("Docopt result: \(result)")

Installation

Swift:

  • Check out docopt.swift
  • Add docopt folder to your project

Swift Package Manager:

.package(url: "https://github.com/lf-araujo/docopt.swift", from: "0.0.1"),

Or even easier, simply write a marathon script and add the following to the beginning of it:

import Docopt // marathon: https://github.com/lf-araujo/docopt.swift

License

docopt.swift is released under the MIT License.

About

Friendly fork from docopt.swift, which now works on linux

License:MIT License


Languages

Language:Swift 98.2%Language:Objective-C 1.0%Language:Ruby 0.7%