Skip to content

Instantly share code, notes, and snippets.

@muraoka-edo
Last active August 29, 2015 14:07
Show Gist options
  • Save muraoka-edo/0bf83a7bb4e97156492c to your computer and use it in GitHub Desktop.
Save muraoka-edo/0bf83a7bb4e97156492c to your computer and use it in GitHub Desktop.
[Ruby] optparse template
#!/usr/bin/env ruby
# coding: utf-8
require 'optparse'
params = ARGV.getopts('f:')
prg_name = File.basename(__FILE__)
usage = <<-EOS
-------------------------
Usage: parse [options]
-f FileName
-------------------------
EOS
end
if params['f'].nil?
puts usage
else
if not File.exists?(params['f'])
puts "[Error][#{prg_name}]: No such file: #{params['f']}"
puts usage
end
end
# see also) http://qiita.com/genta/items/785900055a5be2ba5d2c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment