#!/usr/bin/env ruby $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib')) require 'msworddoc-extractor' require 'optparse' def program_name File.basename(File.expand_path(__FILE__)) end OptionParser.new do |opts| opts.banner = "Usage: #{program_name} [options] file" opts.on('-h', '--help', 'Prints this help') do puts opts exit end end.parse! filename = ARGV[0] extension = File.extname(filename) raise 'This text extractor currently only works for .doc files' unless extension == '.doc' doc = MSWordDoc::Extractor.load(filename) puts doc.whole_contents