#!/usr/bin/ruby.ruby2.6 

if File.exist?(docbookrx = (File.expand_path '../../lib/docbookrx', __FILE__))
  require docbookrx
else
  require 'docbookrx'
end

infile = ARGV.shift
strict = false
if (infile == "--strict")
  strict = true
  infile = ARGV.shift
end
unless infile
  warn 'Please specify a DocBook file to convert.'
  exit 1
end

# defaults shown
# TODO cli should allow these to be set
opts = {
#  runin_admonition_label: true,
#  sentence_per_line: true,
#  preserve_line_wrap: false,
#  delimit_source: true,
#  idprefix: '_',
#  idseparator: '_',
#  normalize_ids: true,
#  compat_mode: false,
#  attributes: {
#    'sourcedir' => '.',
#    'uri-example' => 'http://example.org'
#  }
  strict: strict,
  cwd: File.dirname(infile),
  attributes: { imagesdir: './images' }
}

Docbookrx.convert_file infile, opts
exit 0
