Skip to content

ox/pretty_args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pretty Args

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.

Installation

gem install pretty_args

Usage

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.draw

This prints out the following:

program usage:
[options]   <file>
    ┬         ┬
    │         │
    │         └────── the file name
    └──────────────── something about x

Isn't that just pretty? Now go use it.

Alternate Usage

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.draw

Super Large Descriptions

If 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

License

I really don't care for licenses, so use it as you will. However let me know where you use it, just for fun.

About

Display useful and pretty arguments with your application via a branching diagram

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages