Class: VivlioStarter::CLI::SamovarCommands::ResizeCommand

Inherits:
VsCommand
  • Object
show all
Defined in:
lib/vivlio_starter/cli/samovar/resize_command.rb

Overview

resize コマンドの Samovar 実装

Constant Summary

Constants included from OptionTokenNormalizer

OptionTokenNormalizer::BARE_VALUE_DEFAULTS

Instance Method Summary collapse

Methods included from OptionTokenNormalizer

#initialize, prepended

Instance Method Details

#callObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vivlio_starter/cli/samovar/resize_command.rb', line 42

def call
  # --help が未定義だと位置引数 dir に「--help」が落ちてしまう(契約テスト CL-01 で検出)
  if options[:help]
    print_usage
    return 0
  end

  # 前提条件の検証(ProjectRoot ◎ / ImagesDir ◎)
  # 既定の images/ 以外を対象にする場合(vs resize <dir>)は ImagesDir を検証しない
  checks = [Guards::ProjectRootCheck.new]
  checks << Guards::ImagesDirCheck.new if resolve_dir == Common::IMAGES_DIR
  guard_failure = Guards.precheck(*checks)
  return guard_failure if guard_failure

  preset = if options[:high]
             '高精細'
           elsif options[:low]
             '軽量'
           else
             '標準'
           end
  report_result(ResizeCommands.execute_resize_with_preset(preset, resolve_dir, merged_options))
  0
end