Class: VivlioStarter::CLI::SamovarCommands::PdfReadCommand

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

Overview

pdf:read コマンドの Samovar 実装(Public コマンド)

Constant Summary

Constants included from OptionTokenNormalizer

OptionTokenNormalizer::BARE_VALUE_DEFAULTS

Instance Method Summary collapse

Methods included from OptionTokenNormalizer

#initialize, prepended

Instance Method Details

#callObject



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/vivlio_starter/cli/samovar/pdf_command.rb', line 199

def call
  if options[:help] || target.to_s.strip.empty?
    print_usage
    return 0
  end

  # 前提条件の検証(ProjectRoot ○)
  # target は章トークンの場合があるため PdfArtifactCheck は適用せず、
  # PDF パス解決の失敗はドメイン層(MissingPdfError)に委ねる
  guard_failure = Guards.precheck(Guards::RelaxedCheck.new(Guards::ProjectRootCheck.new))
  return guard_failure if guard_failure

  pdf_reader.call
  0
rescue Commands::PdfReadCommand::InvalidInputError => e
  Common.log_error("[pdf:read] #{e.message}")
  1
rescue Commands::PdfReadCommand::MissingPdfError => e
  Common.log_error("[pdf:read] #{e.message}")
  1
rescue StandardError => e
  Common.log_error("[pdf:read] 実行中にエラー: #{e.message}")
  Common.log_error(e.backtrace.first(5).join("\n")) if ENV['VERBOSE']
  1
end