http://homepage1.nifty.com/~tetsu/ruby/intro/arg.html
より、rubyで引数付オプションを使う方法

#! /usr/local/bin/ruby

def usage
 STDERR.print "usage: #{$0} [-echo|-help] arg...\n"
end

separator = "\n"

while ARGV[0] =~ /^-/
 case ARGV.shift
 when '-echo'
   separator = " "
 when '-help'
   usage
   exit
 else
   usage
   exit 1
 end
end

print ARGV.join(separator), "\n"

exit

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2006年09月21日 12:34