Class: VivlioStarter::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

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



87
88
89
# File 'lib/vivlio_starter/cli/samovar/root_command.rb', line 87

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

.internal_commandsObject

内部コマンド (vs --help に非表示、開発者向け) 注: pre_process, convert, post_process, entries, toc, pdf, vivliostyle は build コマンドから内部的に呼び出される純粋な内部処理に移行済み



77
78
79
80
81
82
83
84
# File 'lib/vivlio_starter/cli/samovar/root_command.rb', line 77

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

.public_commandsObject

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



42
43
44
45
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
71
72
# File 'lib/vivlio_starter/cli/samovar/root_command.rb', line 42

def public_commands
  @public_commands ||= {
    'help' => HelpCommand,
    'new' => NewCommand,
    'upgrade' => UpgradeCommand,
    '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:plan' => IndexPlanCommand,
    'index:auto' => IndexAutoCommand,
    'index:apply' => IndexApplyCommand,
    'index:export' => IndexExportCommand,
    'index:import' => IndexImportCommand,
    'pdf:compress' => PdfCompressCommand,
    'pdf:pages' => PdfPagesCommand,
    'pdf:rasterize' => PdfRasterizeCommand,
    'pdf:read' => PdfReadCommand,
    'lint' => LintCommand,
    'metrics' => MetricsCommand,
    'preflight' => PreflightCommand
  }.freeze
end

Instance Method Details

#callObject



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

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