Sha256: f072bfdf19447c850778c423d94de2d9bc75c653f326270eb77bc4e4466ad2f0

Contents?: true

Size: 1.87 KB

Versions: 10

Compression:

Stored size: 1.87 KB

Contents

#!/usr/bin/env ruby

module Distil

  LIB_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
  VENDOR_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "vendor"))
  ASSETS_DIR= File.expand_path(File.join(File.dirname(__FILE__), "..", "assets"))
  APP_NAME= File.basename($0)
  APP_SCRIPT= File.expand_path($0)
  
  $:.unshift(LIB_DIR)

  require 'distil'

  help = %{
  Distil is a tool for building HTML applications from its component CSS &
  Javascript files.
  }.remove_indent

  require 'optparse'

  options = {}
  opts = OptionParser.new do |opts|
    opts.banner = help

    opts.on("--server [PORT]", "Start web server (default port 8888)") do |port|
      options[:server] = true
      options[:server_port] = port unless port.nil?
    end
    
    opts.on("--base URL", "The base path for the server") do |url|
      options[:server_url]= url
    end
    
    opts.on("--project PROJECT", "The project to build") do |project|
      options[:project_file]= project
    end
    
    opts.on("--output-folder FOLDER", "Where to put the build products") do |output_folder|
      options[:output_path]= File.expand_path(output_folder)
    end
  end
  opts.parse!

  if options[:project_file]
    if !File.exist?(options[:project_file])
      puts "#{APP_NAME}: No such file: #{options[:project_file]}"
      exit 1
    end
    project= Project.from_file(options[:project_file])
  else
    project= Project.find(Dir.pwd)
  end
  
  unless project
    puts "#{APP_NAME}: Could not find project to build"
    exit 1
  end

  if options[:output_path]
    project.output_path= options[:output_path]
  end

  begin
    commands= ARGV.empty? ? ['build'] : ARGV
    commands.each { |cmd|
      project.send cmd
    }
  
    project.report
    
    if true==options['server']
      start_server(project, options)
    end
  rescue BuildFailure
    project.report
    exit 1
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
distil-0.14.4 bin/distil
distil-0.14.3 bin/distil
distil-0.14.2 bin/distil
distil-0.14.2.a bin/distil
distil-0.14.1 bin/distil
distil-0.14.1.a bin/distil
distil-0.14.0 bin/distil
distil-0.14.0.i bin/distil
distil-0.14.0.h bin/distil
distil-0.14.0.g bin/distil