Pretty Args is the pretty way to show off your usage dialog. It is perfect for small projects that have a few program arguments. However, pretty_args is powerful enough to handle large argument numbers and descriptions. It's also really simple to set up, give it a whirl.
gem install pretty_args
require 'pretty_args'
#make a collection of arguments
ac = ArgCollection.new
#add a few arguments
ac.add '[options]', 'something about x'
ac.add '<file>', 'the file name'
#draw them to the screen
puts "program usage:"
ac.drawThis prints out the following:
program usage:
[options] <file>
┬ ┬
│ │
│ └────── the file name
└──────────────── something about x
Isn't that just pretty? Now go use it.
require 'pretty_args'
#make the arguments individually
ar1 = Arg.new 'label', 'description'
ar2 = Arg.new '[options]', 'options for x'
#and add them on initialization
ac = ArgCollection.new ar1, ar2
#or individually
ac = ArgCollection.new
ac.add_arg ar1
ac.add_arg ar2
#or as an Array
ac = ArgCollection.new
ac.add_args [ar1,ar2]
#then draw
ac.drawIf you feel so inclined as to have large descriptions for your arguments, that's fine too. Here is a sample output. Nothing has changed about creating the arguments, just the length of the description string.
foo baz fiz52s [options] lol bat [options] [flags]
┬ ┬ ┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ └─────── this is a really long description that wi
│ │ │ │ │ │ │ ll most likely break my application. This
│ │ │ │ │ │ │ is to test if the program correctly hand
│ │ │ │ │ │ │ les really long input strings and parses
│ │ │ │ │ │ │ them the right way.
│ │ │ │ │ │ └────────────────── this is a really long description that wi
│ │ │ │ │ │ ll most likely break my application. This
│ │ │ │ │ │ is to test if the program correctly hand
│ │ │ │ │ │ les really long input strings and parses
│ │ │ │ │ │ them the right way. For instance, the pro
│ │ │ │ │ │ gram should make another set of bars for
│ │ │ │ │ │ every new line that comes from this text.
│ │ │ │ │ │ I think this is long enough.
│ │ │ │ │ └─────────────────────────── mobile
│ │ │ │ └───────────────────────────────── cats
│ │ │ └────────────────────────────────────────── this is a really long description that wi
│ │ │ ll most likely break my application. This
│ │ │ is to test if the program correctly hand
│ │ │ les really long input strings and parses
│ │ │ them the right way. For instance, the pro
│ │ │ gram should make another set of bars for
│ │ │ every new line that comes from this text.
│ │ │ I think this is long enough.
│ │ └──────────────────────────────────────────────────── bizz
│ └─────────────────────────────────────────────────────────── buz
└───────────────────────────────────────────────────────────────── bar
I really don't care for licenses, so use it as you will. However let me know where you use it, just for fun.