GithubHelp home page GithubHelp logo

royalwang / clikit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kylef/commander

0.0 3.0 0.0 239 KB

The swiftest way to write a command line tool

License: BSD 3-Clause "New" or "Revised" License

Swift 96.26% C++ 3.74%

clikit's Introduction

CLIKit

The swiftest way to write a command line tool.

Usage

Code:

var manager = Manager()

manager.register("issue", "Options for issue") { argv in
    println("Say `open`, `close` or `edit`")
}

manager.register("issue open", "Opens a new issue") { argv in
    println("A new issue has been created!")
}

manager.register("issue close", "Closes an open issue") { argv in
    println("Issue has been closed.")
}

manager.register("issue edit", "Edits an issue") { argv in
    if let id = argv.shift() {
        var alert = "Editing issue #\(id). "
        
        if let assignee = argv.option("assignee") {
            alert += "\(assignee) will be the new assignee. "
        }
        
        if let milestone = argv.option("milestone") {
            alert += "The issue must be completed before \(milestone). "
        }
        
        println(alert)
    } else {
        println("Issue id not specified")
    }
}


manager.run()

Result:

$ ./my_cli issue open
A new issue has been created!
$ ./my_cli issue edit 22 --assignee=radex --milestone=2.0
Editing issue #22. radex will be the new assignee. The issue must be completed before 2.0. 
$ ./my_cli issue
Say `open`, `close` or `edit`

Features

  • Specify commands and subcommands
  • Arguments (edit 22)
  • Boolean flags (coffee make --sugar --no-milk)
  • Options (open --title=foo --author=bar)

Authors

License

CLIKit is available under the BSD license. See the LICENSE file for more info.

clikit's People

Contributors

radex avatar kylef avatar neonichu avatar

Watchers

James Cloos avatar Hao.Dongfang 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.