Skip to content
Dave Copeland edited this page Nov 27, 2010 · 18 revisions

Intro

GLI lets you create command-suite (i.e. git-like) style applications in Ruby very easily.

Install

Install if you need to:

> gem install gli

Use

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

> gli init my_proj command_name other_command_name
> my_proj/bin/my_proj help
usage: my_proj command [options]

Version: 0.0.1

Options:
    -f, --flagname=The name of the argument - Describe some flag here (default: 
                                              the default)
    -s, --switch                            - Describe some switch here

Commands:
    command_name       - Describe command_name here
    help               - Shows list of commands or help for one command
    other_command_name - Describe other_command_name here

> my_proj/bin/my_proj help command_name
command_name [options] Describe arguments to command_name here
    Describe command_name here

Options:
    -f arg - Describe a flag to command_name (default: default)
    -s     - Describe a switch to command_name

As you can see, a lot of work has been done fore you, in terms of help output and command-line parsing. This is the point of GLI.

The scaffold project that was created in ./my_proj comes with:

  • executable in ./my_proj/bin/my_proj. This file demonstrates most of what you need to describe your command line interface.
  • an empty test in ./my_proj/test/tc_nothing.rb that can bootstrap your tests
  • 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

See Features for a longer list of GLI's features.

More

Clone this wiki locally