# File lib/asciidoctor/cli/invoker.rb, line 29
      def invoke!
        return if @options.nil?

        begin
          opts = {}
          monitor = {}
          infile = nil
          outfile = nil
          @options.map {|k, v|
            case k
            when :input_file
              infile = v
            when :output_file
              outfile = v
            when :destination_dir
              #opts[:to_dir] = File.expand_path(v) unless v.nil?
              opts[:to_dir] = v unless v.nil?
            when :attributes
              opts[:attributes] = v.dup
            when :verbose
              opts[:monitor] = monitor if v
            when :trace
              # currently, nothing
            else
              opts[k] = v unless v.nil?
            end
          }

          if infile == '-'
            # allow use of block to supply stdin, particularly useful for tests
            input = block_given? ? yield : STDIN
          else
            input = File.new(infile)
          end

          if outfile == '-' || (infile == '-' && (outfile.to_s.empty? || outfile != '/dev/null'))
            opts[:to_file] = (@out || $stdout)
          elsif !outfile.nil?
            opts[:to_file] = outfile
          else
            opts[:in_place] = true unless opts.has_key? :to_dir
          end

          @document = Asciidoctor.render(input, opts)

          # FIXME this should be :monitor, :profile or :timings rather than :verbose
          if @options[:verbose]
            puts "Time to read and parse source: #{'%05.5f' % monitor[:parse]}"
            puts "Time to render document: #{'%05.5f' % monitor[:render]}"
            puts "Total time to read, parse and render: #{'%05.5f' % monitor[:load_render]}"
          end
        rescue Exception => e
          raise e if @options[:trace] || SystemExit === e
          err = (@err || $stderr)
          err.print "#{e.class}: " if e.class != RuntimeError
          err.puts e.message
          err.puts '  Use --trace for backtrace'
          @code = 1
        end
      end