Class: MyManga::CLI::Commands::Zine

Inherits:
MyManga::CLI::Command show all
Defined in:
lib/my_manga/zine.rb

Overview

See desc

Constant Summary collapse

TMP_DIR =
File.expand_path('../../tmp', __dir__)

Instance Method Summary collapse

Methods inherited from MyManga::CLI::Command

#manga_names, #pad

Instance Method Details

#call(names: nil, **options) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/my_manga/zine.rb', line 29

def call(names: nil, **options)
  names = manga_names(names)
  filename = options.fetch(:filename) { nil }
  size = options.fetch(:size).to_i

  if options[:add] && options[:remove]
    puts "--add and --remove are mutually exclusive"
    exit 1
  end

  if options[:add]
    MyManga.add_to_zine(names)
    puts %("#{names.join(', ')}" added to the zine!)
  elsif options[:remove]
    MyManga.remove_from_zine(names)
    puts %("#{names.join(', ')}" removed from the zine!)
  else
    publish(filename, size)
  end
end