def process
      args = @args.dup
      unless @options[:input]
        file = args.shift
        if file
          @options[:file] = file
          @options[:input] = File.open(file, 'r')
        else
          @options[:file] = 'STDIN'
          @options[:input] = $stdin
        end
      end

      locals = @options.delete(:locals) || {}
      result =
        if @options[:erb]
          require 'slim/erb_converter'
          ERBConverter.new(file: @options[:file]).call(@options[:input].read)
        elsif @options[:compile]
          Engine.new(file: @options[:file]).call(@options[:input].read)
        else
          Template.new(@options[:file]) { @options[:input].read }.render(nil, locals)
        end

      rescue Exception => ex
        raise ex if @options[:trace] || SystemExit === ex
        $stderr.print "#{ex.class}: " if ex.class != RuntimeError
        $stderr.puts ex.message
        $stderr.puts '  Use --trace for backtrace.'
        exit 1
      else
        unless @options[:output]
          file = args.shift
          @options[:output] = file ? File.open(file, 'w') : $stdout
        end
        @options[:output].puts(result)
        exit 0
    end
def process
      args = @args.dup
      unless @options[:input]
        file = args.shift
        if file
          @options[:file] = file
          @options[:input] = File.open(file, 'r')
        else
          @options[:file] = 'STDIN'
          @options[:input] = $stdin
        end
      end

      locals = @options.delete(:locals) || {}
      result =
        if @options[:erb]
          require 'slim/erb_converter'
          ERBConverter.new(file: @options[:file]).call(@options[:input].read)
        elsif @options[:compile]
          Engine.new(file: @options[:file]).call(@options[:input].read)
        else
          Template.new(@options[:file]) { @options[:input].read }.render(nil, locals)
        end

      rescue Exception => ex
        raise ex if @options[:trace] || SystemExit === ex
        $stderr.print "#{ex.class}: " if ex.class != RuntimeError
        $stderr.puts ex.message
        $stderr.puts '  Use --trace for backtrace.'
        exit 1
      else
        unless @options[:output]
          file = args.shift
          @options[:output] = file ? File.open(file, 'w') : $stdout
        end
        @options[:output].puts(result)
        exit 0
    end
Process command