Sha256: 1c1504a30f8a93b353fe9dfeb2a1ae3b0ec0d1953be55d1b9759c751166c330c
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'optparse' module EbookRenamer::Options def parse_options() options = {} option_parser = OptionParser.new do |opts| opts.banner = <<-END.gsub(/^\s+\|/, '') | | Usage: ebook_renamer [options] | | Examples: | | 1) $ebook_renamer | | 2) $ebook_renamer --base-dir ~/Dropbox/ebooks | | 3) $ebook_renamer --base-dir ~/Dropbox/ebooks | --recursive | | 4) $ebook_renamer --base-dir ~/Dropbox/ebooks | --recursive | | 5) $ebook_renamer --base-dir ~/Dropbox/ebooks | --recursive | --commit | | Options: | END options[:base_dir] ||= Dir.pwd opts.on('-b', '--base-dir directory', 'Starting directory [default - current directory]') do |base_dir| options[:base_dir] = base_dir end options[:recursive] = false opts.on('-r', '--recursive', 'Process the files recursively [default - false]') do options[:recursive] = true end options[:commit] = false opts.on('-c', '--commit', 'Perform the actual rename [default - false]') do options[:commit] = true end opts.on('-v', '--version', 'Display version number') do puts EbookRenamer::VERSION exit 0 end opts.on('-h', '--help', 'Display this screen') do puts opts exit 0 end end option_parser.parse! options end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ebook_renamer-0.0.2 | lib/ebook_renamer/options.rb |
ebook_renamer-0.0.1 | lib/ebook_renamer/options.rb |