Guest

chuck

By: a guest on Sep 27th, 2009  |  syntax: Ruby  |  size: 0.61 KB  |  hits: 69  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #!/usr/bin/env ruby
  2. require 'optparse'
  3.  
  4. # create an empty hash to hold the options
  5. options = {}
  6.  
  7. optparse = OptionParser.new do|opts|
  8.     opts.banner = "Usage: shift_subtitle [options] file1 file2"
  9.  
  10.     opts.on('-h', '--help', 'Display this screen') do
  11.         puts opts
  12.         exit
  13.     end
  14.     opts.on('-o', '--operation STR', 'What type of operation to use') do|o|
  15.         options[:operation] = o
  16.     end
  17.     opts.on('-t', '--time NUM', 'Amount of time to shift') do|t|
  18.         options[:time] = t
  19.     end
  20. end
  21.  
  22. optparse.parse!
  23.  
  24. options[:file1] = ARGV[0] if ARGV[0]
  25. options[:file2] = ARGV[1] if ARGV[1]