lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

option_parse-{-..-}-(optp).sublime-snippet (587B)


      1 <snippet>
      2 	<content><![CDATA[require "optparse"
      3 
      4 options = {${1::default => "args"}}
      5 
      6 ARGV.options do |opts|
      7 	opts.banner = "Usage:  #{File.basename(\$PROGRAM_NAME)} [OPTIONS]${2/^\s*$|(.*\S.*)/(?1: )/}${2:OTHER_ARGS}"
      8 	
      9 	opts.separator ""
     10 	opts.separator "Specific Options:"
     11 	
     12 	$0
     13 	
     14 	opts.separator "Common Options:"
     15 	
     16 	opts.on( "-h", "--help", "Show this message." ) do
     17 		puts opts
     18 		exit
     19 	end
     20 	
     21 	begin
     22 		opts.parse!
     23 	rescue
     24 		puts opts
     25 		exit
     26 	end
     27 end
     28 ]]></content>
     29 	<tabTrigger>optp</tabTrigger>
     30 	<scope>source.ruby</scope>
     31 	<description>option_parse { .. }</description>
     32 </snippet>