Sha256: e0c4372093de34ae4dca1ebd528200d2c0c34880b8eb251d5ece379d257e5343

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

require 'coffee_without_nodejs'
require 'coderay'

if File.pipe?($stdin)
  content = CoffeeWithoutNodejs.compile($stdin.read).to_s
  unless content.empty?
    token = CodeRay.scan(content, :js)
    print $stdout.tty? ? token.terminal : token.text
  end
  exit
end

if ARGV.empty?
  `notify-send 'Starting coffee compiler.' -t 1000` if system 'which notify-send &>/dev/null'
  CoffeeWithoutNodejs.watch!
  exit
end

if ['-h', '--help'].include? ARGV.first
  STDERR.puts 'coff -e "coffee script", to compile coffee to javascript.'
  exit
end

if ['-e', '--eval'].include? ARGV.first
  ARGV.shift
  content = CoffeeWithoutNodejs.compile(ARGV.first).to_s
  print CodeRay.scan(content, :js).terminal unless content.empty?
  exit
end

if test 'd', ARGV.first
  Dir.chdir(ARGV.first) { CoffeeWithoutNodejs.watch! }
  exit
end

ARGV.each do |file|
  unless File.exist? file
    puts "cannot open \`#{file}' for reading: No such file or directory, Skipping"
    next
  end

  content = CoffeeWithoutNodejs.compile(file).to_s
  unless content.empty?
    token = CodeRay.scan(content, :js)
    print $stdout.tty? ? token.terminal : token.text
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coffee_without_nodejs-0.11.0 bin/coff
coffee_without_nodejs-0.10.0 bin/coff
coffee_without_nodejs-0.9.0 bin/coff