Git Product home page Git Product logo

docopt.swift's Introduction

build status docopt.swift is a Swift port of docopt

docopt.swift helps you create most beautiful command-line interfaces easily:

Swift:

let doc : String = "Not a serious example.\n" +
"\n" +
"Usage:\n" +
"  calculator_example.py <value> ( ( + | - | * | / ) <value> )...\n" +
"  calculator_example.py <function> <value> [( , <value> )]...\n" +
"  calculator_example.py (-h | --help)\n" +
"\n" +
"Examples:\n" +
"  calculator_example.py 1 + 2 + 3 + 4 + 5\n" +
"  calculator_example.py 1 + 2 '*' 3 / 4 - 5    # note quotes around '*'\n" +
"  calculator_example.py sum 10 , 20 , 30 , 40\n" +
"Options:\n" +
"  -h, --help\n"

var args = Process.arguments
args.removeAtIndex(0) // arguments[0] is always the program_name
let result = Docopt.parse(doc, argv: args, help: true, version: "1.0")
println("Docopt result: \(result)")

Objective-C:

NSArray *arguments = [[NSProcessInfo processInfo] arguments];
arguments = arguments.count > 1 ? [arguments subarrayWithRange:NSMakeRange(1, arguments.count - 1)] : @[];

NSDictionary *result = [Docopt parse:doc argv:arguments help:YES version:@"1.0" optionsFirst:NO];
NSLog(@"Docopt result:\n%@", result);

Installation

Swift:

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

Objective-C:

  • Check out docopt.swift
  • Build Docopt target
  • Add Docopt.framework to your project

License

docopt.swift is released under the MIT License.

docopt.swift's People

Contributors

kovpas avatar matteomecucci-tomtom avatar neonichu avatar ttilley avatar

Watchers

 avatar  avatar

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.