/ruby-mode/Files/option_parse { .. } (optp).yasnippet
Unknown | 32 lines | 25 code | 7 blank | 0 comment | 0 complexity | cf0116eecc51cf79583b43976df58873 MD5 | raw file
- # -*- mode: snippet -*-
- # key: optp
- # contributor: Translated from TextMate Snippet
- # name: option_parse { .. }
- # --
- require "optparse"
- options = {${1::default => "args"}}
- ARGV.options do |opts|
- opts.banner = "Usage: #{File.basename(\$PROGRAM_NAME)} [OPTIONS]${2/^\s*$|(.*\S.*)/(?1: )/}${2:OTHER_ARGS}"
-
- opts.separator ""
- opts.separator "Specific Options:"
-
- $0
-
- opts.separator "Common Options:"
-
- opts.on( "-h", "--help",
- "Show this message." ) do
- puts opts
- exit
- end
-
- begin
- opts.parse!
- rescue
- puts opts
- exit
- end
- end