#!/usr/bin/ruby.ruby4.0 

if File.file?(asciidoctor_revealjs = (File.expand_path '../../lib/asciidoctor-revealjs.rb', __FILE__))
  require asciidoctor_revealjs
else
  require 'asciidoctor-revealjs'
end
require 'asciidoctor/cli'

options = Asciidoctor::Cli::Options.new backend: 'revealjs'

# FIXME (from asciidoctor-pdf) provide an API in Asciidoctor for sub-components to print version information
unless ARGV != ['-v'] && (ARGV & ['-V', '--version']).empty?
  $stdout.write %(Asciidoctor reveal.js #{Asciidoctor::Revealjs::VERSION} using )
  options.print_version
  exit 0
end

# FIXME (from bespoke) This is a really bizarre API. Please make me simpler.
if Integer === (result = options.parse! ARGV)
  exit result
else
  invoker = Asciidoctor::Cli::Invoker.new options
  GC.start
  invoker.invoke!
  exit invoker.code
end
