[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

option parser: decrease distance between arg and explanation

Patrick Gundlach

1/23/2007 9:50:00 AM

Hi all,

I use option parser and I would like to decrease a distance in the
output. Example:

#!/usr/bin/env ruby

require "optparse"

a=ARGV.options { |opts|
opts.on("-a","--all","do everything")
opts.on("-h","--help") do
puts opts
exit 0
end
opts.parse!
}

result:

Usage: optparsetest [options]
-a, --all do everything
-h, --help


I'd like to decrease the distance between "--all" and "do everything,
such as

Usage: optparsetest [options]
-a, --all do everything
-h, --help

Anybody know how to achieve this?

Thanks,

Patrick

--
Posted via http://www.ruby-....

2 Answers

Jano Svitok

1/23/2007 2:55:00 PM

0

On 1/23/07, Patrick Gundlach <rubyforum@contextgarden.net> wrote:
> Hi all,
>
> I use option parser and I would like to decrease a distance in the
> output. Example:
>
> #!/usr/bin/env ruby
>
> require "optparse"
>
> a=ARGV.options { |opts|
+ opts.summary_width = 10
> opts.on("-a","--all","do everything")
> opts.on("-h","--help") do
> puts opts
> exit 0
> end
> opts.parse!
> }
>
> result:
>
> Usage: optparsetest [options]
> -a, --all do everything
> -h, --help
>
>
> I'd like to decrease the distance between "--all" and "do everything,

use OptionParser#summary_width

http://ruby-doc.org/core/classes/OptionP..., or RTFineS (they
are pretty readable) ;-)

Patrick Gundlach

1/23/2007 3:06:00 PM

0

Hello Jan,

> use OptionParser#summary_width
>
> http://ruby-doc.org/core/classes/OptionP..., or RTFineS (they
> are pretty readable) ;-)

thanks for the answer, it is more verbose then the file I had on my
harddisk. I've got it to work now.

Thanks again,

Patrick

--
Posted via http://www.ruby-....