Sha256: d494fbe24826c84eb4d2922d090ee70429db9b04c94e6ec0dc4c094a717ed47a

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

#!/usr/bin/env ruby

lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)

require 'optparse'
require 'propre'

options = {}
OptionParser.new do |opt|
  opt.banner = "Usage: #{ File.basename($0) } [OPTION]... SOURCE..."

  opt.on('-i', '--interactive', 'Run interactively') do |v|
    options[:interactive] = v
  end

  opt.on('-R', '--recursive', 'Run recursively') do |v|
    options[:recursive] = v
  end

  opt.on('-V', '--video-only', 'Search for video files only') do |v|
    options[:videonly] = v
  end

  opt.on('-s', '--sanitize', 'Sanitize filename before search') do |v|
    options[:sanitize] = v
  end

  opt.on('-d', '--dotfile', 'Don\'t ignore .dotfile') do |v|
    options[:dotfile] = v
  end

  opt.on_tail("-v", "--version", "Show version information about this program and quit.") do
    puts "#{Propre} - v#{Propre::VERSION}"
    exit
  end

  opt.on_tail("-h", "--help", "--usage", "Show this help message and quit.") do |v|
    puts opt.help
    exit
  end

  options[:help] = opt.help

end.parse!

def main(options)
  if ARGV.size < 1
    puts options[:help]
  else
    propre = Propre.new(options)
    if File.directory?(ARGV[0])
      puts "Searching for movies in directory..."
      propre.crawlDirectory(ARGV[0])
    end

    if File.file?(ARGV[0])
      puts "Searching for movie title..."
      if !propre.searchMovieFromFile(ARGV[0])
        puts "No movie found for #{ARGV[0]}"
      end
    end
  end
end

begin
  main(options)
rescue Interrupt
  puts "\nExiting..."  
rescue StandardError => e
  puts e
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
propre-0.1.1 bin/propre