Method: Traject::CommandLine#execute
- Defined in:
- lib/traject/command_line.rb
#execute ⇒ Object
Returns true on success or false on failure; may also raise exceptions; may also exit program directly itself (yeah, could use some normalization)
40 41 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/traject/command_line.rb', line 40 def execute if [:version] self.console.puts "traject version #{Traject::VERSION}" return end if [:help] self.console.puts slop.help return end ([:load_path] || []).each do |path| $LOAD_PATH << path unless $LOAD_PATH.include? path end arg_check! self.indexer = initialize_indexer! ###### # SAFE TO LOG to indexer.logger starting here, after indexer is set up from conf files # with logging config. ##### indexer.logger.info("traject (#{Traject::VERSION}) executing with: `#{orig_argv.join(' ')}`") # Okay, actual command process! All command_ methods should return true # on success, or false on failure. result = case [:command] when "process" (io, filename) = get_input_io(self.remaining_argv) indexer.settings['command_line.filename'] = filename if filename indexer.process(io) when "marcout" (io, filename) = get_input_io(self.remaining_argv) indexer.settings['command_line.filename'] = filename if filename command_marcout!(io) when "commit" command_commit! else raise ArgumentError.new("Unrecognized traject command: #{options[:command]}") end return result rescue Exception => e # Try to log unexpected exceptions if possible indexer && indexer.logger && indexer.logger.fatal("Traject::CommandLine: Unexpected exception, terminating execution: #{Traject::Util.exception_to_log_message(e)}") rescue nil raise e end |