Class: Archiver::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/archiver/cli.rb

Instance Method Summary collapse

Instance Method Details

#renaming(destination) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/archiver/cli.rb', line 17

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