Class: Vivlio::Starter::CLI::SamovarCommands::IndexAutoCommand

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/vivlio/starter/cli/samovar/index_command.rb

Overview

index:auto コマンド - 全自動索引候補抽出

Instance Method Summary collapse

Instance Method Details

#callObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/vivlio/starter/cli/samovar/index_command.rb', line 68

def call
  return print_usage if options[:help]

  ENV['VERBOSE'] = '1' if options[:verbose]

  # auto_discovery 設定を確認
  config = Common::CONFIG['index'] || {}
  unless config.fetch('auto_discovery', true)
    Common.log_info('index.auto_discovery: false のため、自動候補抽出は無効です')
    Common.log_info('手動マークアップ [用語|読み] のみが索引に反映されます')
    Common.log_info('自動抽出を有効にするには book.yml で auto_discovery: true を設定してください')
    return 0
  end

  chapters = IndexCommands.resolve_chapters(files || [])

  manager = UnifiedIndexManager.new
  manager.auto_process!(chapters)
  0
rescue SystemExit => e
  raise e
rescue StandardError => e
  Common.log_error("index:auto 実行中にエラー: #{e.message}")
  Common.log_error(e.backtrace.first(5).join("\n")) if ENV['VERBOSE']
  1
end