Class: Vivlio::Starter::CLI::SamovarCommands::RootCommand

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

Overview

Samovar CLI のルートコマンド

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.command_mapObject

全コマンドマップ (ルーティング用)



86
87
88
# File 'lib/vivlio/starter/cli/samovar/root_command.rb', line 86

def command_map
  @command_map ||= public_commands.merge(internal_commands).freeze
end

.internal_commandsObject

内部コマンド (vs –help に非表示、開発者向け) 注: pre_process, convert, post_process, entries, toc, vivliostyle は

build コマンドから内部的に呼び出される純粋な内部処理に移行済み


75
76
77
78
79
80
81
82
83
# File 'lib/vivlio/starter/cli/samovar/root_command.rb', line 75

def internal_commands
  @internal_commands ||= {
    'pdf' => PdfCommand,
    'create:cover' => CreateCoverCommand,
    'create:titlepage' => CreateTitlepageCommand,
    'create:colophon' => CreateColophonCommand,
    'create:legalpage' => CreateLegalpageCommand
  }.freeze
end

.public_commandsObject

利用者向け Public Commands (vs –help に表示)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vivlio/starter/cli/samovar/root_command.rb', line 46

def public_commands
  @public_commands ||= {
    'help' => HelpCommand,
    'new' => NewCommand,
    'build' => BuildCommand,
    'clean' => CleanCommand,
    'delete' => DeleteCommand,
    'doctor' => DoctorCommand,
    'import' => ImportCommand,
    'create' => CreateCommand,
    'rename' => RenameCommand,
    'renumber' => RenumberCommand,
    'open' => OpenCommand,
    'cover' => CoverCommand,
    'resize' => ResizeCommand,
    'index' => IndexCommand,
    'index:auto' => IndexAutoCommand,
    'index:apply' => IndexApplyCommand,
    'pdf:compress' => PdfCompressCommand,
    'pdf:read' => PdfReadCommand,
    'lint' => LintCommand,
    'metrics' => MetricsCommand,
    'preflight' => PreflightCommand
  }.freeze
end

Instance Method Details

#callObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/vivlio/starter/cli/samovar/root_command.rb', line 93

def call
  mark_cli_context

  return print_version if options[:version]

  set_verbose_flag if options[:verbose]

  return help_command.call if options[:help]

  target = command || help_command
  ensure_project_context!(target)
  target.call || 0
rescue SystemExit => e
  e.status
end