Class: Vivlio::Starter::CLI::DeleteCommands::DeleteCommandExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio/starter/cli/delete.rb

Overview

delete コマンドの制御フローを担う実行クラス

オプション解釈・対象解決・削除処理の各責務を分離し、テスト容易性と保守性を確保している。

Instance Method Summary collapse

Constructor Details

#initialize(options_source, tokens) ⇒ DeleteCommandExecutor

Returns a new instance of DeleteCommandExecutor.

Parameters:

  • options_source (Hash, Object)

    オプション情報

    • Hash: { force: true, verbose: false }

    • Object: #options メソッドで Hash を返すオブジェクト

  • tokens (Array<String>)

    削除対象の指定

    • 章番号: “11” → 11-*.md にマッチ

    • 範囲: “11-13” → 11〜13 番の章すべて

    • ファイル名: “11-install” → 11-install.md



47
48
49
50
51
# File 'lib/vivlio/starter/cli/delete.rb', line 47

def initialize(options_source, tokens)
  @options = DeleteOptions.new(options_source)
  @resolver = TargetResolver.new(tokens)
  @deletion = ChapterDeletion.new(@options)
end

Instance Method Details

#callvoid

This method returns an undefined value.

削除処理を実行する

Raises:

  • (SystemExit)

    対象が見つからない場合 exit(1)



57
58
59
60
61
62
# File 'lib/vivlio/starter/cli/delete.rb', line 57

def call
  options.apply_verbose!
  ensure_targets!

  targets.each { |basename| deletion.remove(basename) }
end