Class: Longleaf::CLI
Overview
Main commandline interface setup for Longleaf using Thor.
Class Method Summary collapse
-
.add_shared_option(name, group, options = {}) ⇒ Object
Register a shared method option in a shared option group.
-
.shared_options_group(group_name) ⇒ Object
Add all of the shared options in the specified group as method options.
Instance Method Summary collapse
- #__print_version ⇒ Object
-
#deregister ⇒ Object
Deregister event command.
- #preserve ⇒ Object
-
#register ⇒ Object
Register event command.
- #reindex ⇒ Object
- #setup_index ⇒ Object
-
#validate_config ⇒ Object
Application configuration validation command.
-
#validate_metadata ⇒ Object
File metadata validation command.
Methods included from Logging
#initialize_logger, initialize_logger, logger, #logger
Class Method Details
.add_shared_option(name, group, options = {}) ⇒ Object
Register a shared method option in a shared option group
20 21 22 23 24 |
# File 'lib/longleaf/cli.rb', line 20 def self.add_shared_option(name, group, = {}) @shared_groups = {} if @shared_groups.nil? @shared_groups[group] = {} if @shared_groups[group].nil? @shared_groups[group][name] = end |
.shared_options_group(group_name) ⇒ Object
Add all of the shared options in the specified group as method options
27 28 29 30 31 |
# File 'lib/longleaf/cli.rb', line 27 def self.(group_name) @shared_groups[group_name].each do |opt_name, opt| option opt_name, opt end end |
Instance Method Details
#__print_version ⇒ Object
87 88 89 |
# File 'lib/longleaf/cli.rb', line 87 def __print_version puts "longleaf version #{Longleaf::VERSION}" end |
#deregister ⇒ Object
Deregister event command
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/longleaf/cli.rb', line 166 def deregister verify_config_provided() setup_logger() app_config_manager = load_application_config() file_selector = SelectionOptionsParser.create_registered_selector(, app_config_manager) command = DeregisterCommand.new(app_config_manager) exit command.execute(file_selector: file_selector, force: [:force]) end |
#preserve ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/longleaf/cli.rb', line 185 def preserve verify_config_provided() setup_logger() extend_load_path([:load_path]) app_config_manager = load_application_config() file_selector = SelectionOptionsParser.create_registered_selector(, app_config_manager) command = PreserveCommand.new(app_config_manager) exit command.execute(file_selector: file_selector, force: [:force]) end |
#register ⇒ Object
Register event command
143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/longleaf/cli.rb', line 143 def register verify_config_provided() setup_logger() app_config_manager = load_application_config() file_selector, digest_provider, physical_provider = SelectionOptionsParser .(, app_config_manager) command = RegisterCommand.new(app_config_manager) exit command.execute(file_selector: file_selector, force: [:force], digest_provider: digest_provider, physical_provider: physical_provider) end |
#reindex ⇒ Object
247 248 249 250 251 252 253 |
# File 'lib/longleaf/cli.rb', line 247 def reindex verify_config_provided() setup_logger() app_config_manager = load_application_config() exit Longleaf::ReindexCommand.new(app_config_manager).execute(only_if_stale: [:if_stale]) end |
#setup_index ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/longleaf/cli.rb', line 225 def setup_index verify_config_provided() setup_logger() app_config_manager = load_application_config() if app_config_manager.index_manager.using_index? app_config_manager.index_manager.setup_index logger.success("Setup of index complete") exit 0 else logger.failure("No index configured, unable to perform setup.") exit 1 end end |
#validate_config ⇒ Object
Application configuration validation command
200 201 202 203 204 205 206 |
# File 'lib/longleaf/cli.rb', line 200 def validate_config verify_config_provided() setup_logger() extend_load_path([:load_path]) exit Longleaf::ValidateConfigCommand.new([:config]).execute end |
#validate_metadata ⇒ Object
File metadata validation command
213 214 215 216 217 218 219 220 221 |
# File 'lib/longleaf/cli.rb', line 213 def verify_config_provided() setup_logger() app_config_manager = load_application_config() file_selector = SelectionOptionsParser.create_registered_selector(, app_config_manager) exit Longleaf::ValidateMetadataCommand.new(app_config_manager).execute(file_selector: file_selector) end |