Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   option parser: decrease distance between arg and explanation (http://www.velocityreviews.com/forums/t837470-option-parser-decrease-distance-between-arg-and-explanation.html)

Patrick Gundlach 01-23-2007 09:49 AM

option parser: decrease distance between arg and explanation
 
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-forum.com/.


Jan Svitok 01-23-2007 02:55 PM

Re: option parser: decrease distance between arg and explanation
 
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/OptionParser.html, or RTFineS (they
are pretty readable) ;-)


Patrick Gundlach 01-23-2007 03:06 PM

Re: option parser: decrease distance between arg and explana
 
Hello Jan,

> use OptionParser#summary_width
>
> http://ruby-doc.org/core/classes/OptionParser.html, 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-forum.com/.



All times are GMT. The time now is 09:00 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.