Class: VivlioStarter::CLI::SamovarCommands::OpenCommand

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

Overview

open コマンド - 生成されたPDFを開く

Constant Summary

Constants included from OptionTokenNormalizer

VivlioStarter::CLI::SamovarCommands::OptionTokenNormalizer::BARE_VALUE_DEFAULTS

Instance Method Summary collapse

Methods included from OptionTokenNormalizer

#initialize, prepended

Instance Method Details

#callObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vivlio_starter/cli/samovar/open_command.rb', line 30

def call
  apply_verbose

  if options[:help]
    print_usage
    return 0
  end

  # 前提条件の検証(ProjectRoot ○)
  # target は拡張子省略・sources/ 探索などの自動解決があるため
  # PdfArtifactCheck は適用せず、解決失敗はドメイン層のメッセージに委ねる
  guard_failure = Guards.precheck(Guards::RelaxedCheck.new(Guards::ProjectRootCheck.new))
  return guard_failure if guard_failure

  PdfCommands.execute_open_pdf(build_options, target)
  0
rescue SystemExit => e
  raise e
rescue StandardError => e
  Common.log_error("open 実行中にエラー: #{e.message}")
  Common.log_error(e.backtrace.first(5).join("\n")) if ENV['VERBOSE']
  1
end