Question

According to this post, RDoc::usage is not currently available in ruby 1.9. Are there any good replacements available?

I'd be interested to hear what's available from the standard install as well as what's available from gems.

Was it helpful?

Solution

I like OptionParser (the thing that the article mentions that RDoc::usage is useful to complement).

It looks like any 1.9 bugs have been patched.

OTHER TIPS

In feature request 2713, the rdoc maintainer has stated that he won't add rdoc/usage or any similar feature back to rdoc, saying that OptionParser should be used instead.

We use OptionParser for all new scripts,but had about 100+ that used RDoc. Instead of rewrite each one I wrote this method (BB is our company's namespace. change that to whatever you like ). It works great. The syntax is slightly different, but its help text so we don't mind. Hope it helps!

I then used sed to find all the scripts and change them.

grep -rl "RDoc::usage" * | xargs sed -i "/rdoc\/usage/ s/RDoc/BB/"
grep -rl "BB::usage" * | xargs sed -i "/rdoc\/usage/ s/rdoc/lib\/bb/"

-

module BB
    def BB::usage( exit_code )

        File::open( $0, 'r').readlines.each_with_index do | line, idx |
            next if idx == 0
            if( line =~ /^#/ )
                puts line.gsub(/^#\ ?/,'')
            else
                puts #RDoc adds extra line so we do too
                exit( exit_code )
            end
        end
    end
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top