Method: Traject::CommandLine#get_input_io

Defined in:
lib/traject/command_line.rb

#get_input_io(argv) ⇒ Array<#read>, String

Returns:

  • (Array<#read>, String)


145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/traject/command_line.rb', line 145

def get_input_io(argv)
  filename = nil
  io_arr = nil
  if options[:stdin]
    indexer.logger.info("Reading from standard input")
    io_arr = [$stdin]
  elsif argv.length == 0
    io_arr = [File.open(File::NULL, 'r')]
    indexer.logger.info("Warning, no file input given. Use command-line argument '--stdin' to use standard input ")
  else
    io_arr = argv.collect { |path| File.open(path, 'r') }
    filename = argv.join(",")
    indexer.logger.info "Reading from #{filename}"
  end

  return io_arr, filename
end