We use OptionParser for all new scripts, but had about 100+ that used RDoc. Instead of rewriting each of them, I wrote this method (BB is our companyβs namespace, change it to whatever you like). It works great. The syntax is a little different, but its text helps, so we don't mind. Hope this helps!
Then I used sed to find all the scripts and modify 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
source share