Sha256: 0b0af5df6d149dcfcfc6e8e6f0471de7debdf1d580ded838f5216637731d5a47

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# -*- 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archiver-0.1.0 lib/archiver/cli.rb