Skip to content
This repository

Make awesome command-line applications the easy way

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin refactor the rdoc feature July 27, 2012
Octocat-spinner-32 features
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE.txt added license. D'oh. September 26, 2010
Octocat-spinner-32 ObjectModel.graffle update model March 24, 2012
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 gli.cheat updated cheat November 11, 2011
Octocat-spinner-32 gli.gemspec
Octocat-spinner-32 gli.rdoc Bumping version September 19, 2012
README.rdoc

Git-Like Interface Command Line Parser

GLI is the best way to make a “command-suite” command-line application, e.g. one like git (for the best way to make a simpler command-line application, check out methadone).

GLI allows you to make a very polished, easy-to-maintain command-line application without a lot of syntax, but without restricting you in any way from the power of OptionParser.

Use

Install if you need to:

gem install gli

The simplest way to get started is to create a scaffold project

gli init todo list add complete

This will create a basic scaffold project in ./todo with:

  • executable in ./todo/bin/todo. This file demonstrates most of what you need to describe your command line interface.

  • an empty test in ./todo/test/default_test.rb that can bootstrap your tests

  • an empty feature in ./todo/features/todo.feature that can bootstrap testing your CLI via Aruba.

  • a gemspec shell

  • a README shell

  • Rakefile that can generate RDoc, package your Gem and run tests

  • A Gemfile suitable for use with Bundler to manage development-time dependencies

Now, you are ready to go:

> cd todo
> bundle exec bin/todo help
NAME
    todo - Describe your application here

SYNOPSIS
    todo [global options] command [command options] [arguments...]

VERSION
    0.0.1

GLOBAL OPTIONS
    -f, --flagname=The name of the argument - Describe some flag here (default: the default)
    --help                                  - Show this message
    -s, --[no-]switch                       - Describe some switch here

COMMANDS
    add      - Describe add here
    complete - Describe complete here
    help     - Shows a list of commands or help for one command
    list     - Describe list here

> bundle exec bin/todo help list
NAME
    list - Describe list here

SYNOPSIS
    todo [global options] list [command options] Describe arguments to list here

COMMAND OPTIONS
    -f arg - Describe a flag to list (default: default)
    -s     - Describe a switch to list

All you need to do is fill in the documentation and your code; the help system, command-line parsing and many other awesome features are all handled for you.

Get a more detailed walkthrough on the main site

Supported Platforms

Known to work on

  • 1.8.7

  • 1.9.2

  • 1.9.3

  • Ruby Enterprise Edition 1.8.7

  • Rubinius 1.0.1

  • JRuby 1.6.4

If you're interested in other versions of Ruby, let me know, and I'll add them to my test suite

Documentation

Extensive documentation is available at the wiki.

API Documentation is available here. Recommend starting with GLI::DSL or GLI::App.

Credits

Author

Dave Copeland (davetron5000 at g mail dot com)

Copyright

Copyright © 2010 by Dave Copeland

License

Distributes under the Apache License, see LICENSE.txt in the source distro

Links

gli CLI documentation

:include:gli.rdoc

Something went wrong with that request. Please try again.