# -*- encoding : utf-8 -*- # Created by Thomas Boerger on 2012-03-16. # Copyright (c) 2012. All rights reserved. require 'thor' require 'progressbar' module Archiver class Cli < Thor include Thor::Actions method_option :verbose, :type => :boolean, :aliases => '-V', :default => false method_option :source, :type => :string, :aliases => '-s', :default => '.' desc 'renaming [DESTINATION]', 'Rename all files in the defined directory' def renaming(destination) source = options['source'] verbose = options['verbose'] output = Archiver::Output::Cli.new(verbose) begin action = Archiver::Action::Renaming.new( source, destination, output ) action.process rescue Archiver::Error::InvalidDirectory => e raise Thor::Error.new 'Directories does not exist!' rescue => e if verbose raise Thor::Error.new "Some action failed: #{e.message}" else raise Thor::Error.new 'Some action failed!' end end end end end