Code Monkey home page Code Monkey logo

docopt.swift's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.