Class: AozoraZip::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/aozora_zip/cli.rb

Instance Method Summary collapse

Instance Method Details

#unzip(filename) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/aozora_zip/cli.rb', line 22

def unzip(filename)
  dirname = options[:dir] || File.basename(filename, ".*")
  if !options[:dir] && dirname == filename
    raise AozoraZip::Error, "filename #{filename} should have ext, usually `.zip`"
  end

  if options[:verbose]
    puts "unzip #{filename} to #{dirname}"
  end

  AozoraZip::Core.unzip(filename, dirname, verbose: options[:verbose], force: options[:force])
end

#zip(dirname) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/aozora_zip/cli.rb', line 11

def zip(dirname)
  filename = options[:file] || dirname+".zip"
  if options[:verbose]
    puts "zip directory #{dirname} into #{filename}"
  end

  AozoraZip::Core.zip(filename, dirname, verbose: options[:verbose], force: options[:force])
end