#!/usr/bin/env ruby git_path = File.expand_path('../../.git', __FILE__) if File.exist?(git_path) $:.unshift(File.expand_path('../../lib', __FILE__)) $:.unshift(File.expand_path('../../vendor/qwik/lib', __FILE__)) end require "qwik2md" require "optparse" require "pathname" options = {} OptionParser.new {|opts| opts.banner = "Usage: qwik2md [options] " opts.on("-bBASE", "--base=BASE", "Base path for files (ex. `-b path/to/base` will convert `{{file(a.jpg)}}` to `path/to/base.files/a.jpg`)") do |b| options[:base] = b end }.parse! file = Pathname.new(ARGV[0].to_s) base = options.fetch(:base, file.dirname.join(file.basename('.*'))) puts Qwik2md.convert(ARGF.read, base: base)