-
Notifications
You must be signed in to change notification settings - Fork 102
Home
Alan W. Smith edited this page Jan 25, 2014
·
18 revisions
GLI lets you create command-suite (i.e. git-like) style applications in Ruby very easily.
Install if you need to:
> gem install gli
The simplest way to get started is to create a scaffold project. For example, a command-suite app named "todo" that has the commands "list", "add" and "complete" is created with:
> gli init todo list add complete
A new ./todo
directory is created containing the app. View the basic output of the scaffold with:
> cd todo
> bundle exec bin/todo help
Which will output:
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
> 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
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. All you need to do is fill in your app-specific logic.
The scaffold project that was created in ./todo
comes 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 as well as a basic feature file infeatures
that you can run via aruba to do BDD-style tests - a
./todo.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. Also, see an Example of a gli program.
- Reference - List of all DSL methods for GLI
- Subcommands - How to create subcommands
- Controlling Help Output - More details on the various options available for controlling the output of the auto-generated help commands
- Declaring flags and switches - more details on the options available for declaring flags and switches
- Changelog - What's new in each version
- Contributing - How to contribute patches
- Developing - How to set up your development environment for GLI
- RubyDoc
- Source