bin/movie-renamer in movie-renamer-0.0.12 vs bin/movie-renamer in movie-renamer-0.0.15

- old
+ new

@@ -4,28 +4,32 @@ require 'optparse' options = {} OptionParser.new do |opts| - opts.banner = "Usage: #{File.basename($0)} [opts] <name>\nOnly one options each run\nDefault behavior is -f on current working directory" + opts.banner = "Usage: #{File.basename($0)} [-i|-s|-f|-h|-p] <folder>\nDefault behavior is -f on current working directory" opts.on("-h","--help","Display this help") do puts opts exit 0 end opts.on("-i","--imdb","Executes a query on imdb on <movie name>") do options[:imdb] = true end - opts.on("-s","--singlemovie","Acts on a single movie file <file name>") do - options[:single] = true + opts.on("-s","--singlemovie FILE","Acts on a single movie file <file name>") do |f| + options[:single] = f end - opts.on("-f","--folder","Acts on whole folder <folder>") do - options[:folder] = true + opts.on("-f","--folder FOLDER","Acts on whole folder <folder>") do |f| + options[:folder] = f end + + opts.on("-p","--path PATH", "path for moving renamed movies default is tmp/ in current working directory ") do |p| + options[:path] = p + end begin opts.parse!(ARGV) rescue OptionParser::ParseError => warn.message @@ -33,38 +37,44 @@ exit 1 end end -if options.empty? - options[:folder] = true -end - name = ARGV.join(' ') +=begin if options.length != 1 puts "Usage: #{File.basename($0)} [opts] <name>\nOnly one options each run\nDefault behavior is -f on current working directory" end +=end +if options[:path] + MovieRenamer::newpath = options[:path] +end - if options[:folder] - if name - MovieRenamer::folderPath = File.expand_path(name) - else - Movierenamer::folderPath = Dir.pwd - end + MovieRenamer::folderPath = File.expand_path(options[:folder]) MovieRenamer::folderLoop() + exit 0 elsif options[:single] - if name && File.file?(name) - MovieRenamer::folderPath = File.dirname(File.expand_path(name)) - MovieRenamer::editMovie(name) + if File.file?(File.expand_path(options[:single])) + MovieRenamer::folderPath = File.dirname(File.expand_path(options[:single])) + MovieRenamer::editMovie(options[:single]) else puts "Usage: #{File.basename($0)} -s <filename>" exit 1 end + exit 0 elsif options[:imdb] MovieRenamer::suggestMovies(name) + exit 0 +elsif name + MovieRenamer::folderPath = File.expand_path(name) + MovieRenamer::folderLoop() + exit 0 +else + Movierenamer::folderPath = Dir.pwd + MovieRenamer::folderLoop() + exit 0 end -exit 0