Method: Docsplit::CommandLine#run

Defined in:
lib/docsplit/command_line.rb

#runObject

Delegate to the Docsplit Ruby API to perform all extractions.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/docsplit/command_line.rb', line 41

def run
  begin
    case @command
    when :images  then Docsplit.extract_images(ARGV, @options)
    when :pages   then Docsplit.extract_pages(ARGV, @options)
    when :text    then Docsplit.extract_text(ARGV, @options)
    when :pdf     then Docsplit.extract_pdf(ARGV, @options)
    else
      if METADATA_KEYS.include?(@command)
        value = Docsplit.send("extract_#{@command}", ARGV, @options)
        puts value unless value.nil?
      else
        usage
      end
    end
  rescue ExtractionFailed => e
    puts e.message.chomp
    exit(1)
  end
end