Sha256: 13e2b11b5b2fcd0dc764aa1f18051e2ca8e50a98179b57da28bed4fcd00eda10

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby

here = File.expand_path(File.dirname(__FILE__))
$: << File.join(here, '..', 'lib')

require "trollop"
require "rack"
require "deck"
require "deck/rack_app"
require "deck/version"

options = Trollop.options do
  version "deck v#{Deck::VERSION}"
  banner version
  banner "Usage: deck [options] run [slides]"
  opt :port, "Specify alternate port", :default => 4333
end

command = ARGV.shift

case command
when 'build'

  slides = []
  output_path = nil
  output_dir = "."  # for now, since deck.js is relative to the project root

  ARGV.each do |arg|
    # output_dir ||= File.dirname(arg)
    basename ||= File.basename(arg, ".md")
    output_path ||= "#{output_dir}/#{basename}.html"

    slides += Slide.from_file arg
  end

  File.open(output_path, "w") do |file|
    deck = SlideDeck.new :slides => slides
    # deck.to_pretty(:output => file)  # todo: figure out why this doesn't work
    file.write deck.to_pretty
  end

when 'run'
  
  # Fix Rack bug https://github.com/rack/rack/issues/301
  require 'deck/rack_static_patch'
  
  port = options[:port]
  slide_files = ARGV
  Rack::Handler.default.run Deck::RackApp.build(slide_files), :Port => port
  
else
  puts "Unknown command '#{command}'"
  puts <<-USAGE
Usage:
  deck run src.md...
  deck build src.md...
  
see http://github.com/alexch/deck.rb README for more help.

  USAGE
  exit 1
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deckrb-0.2.2 bin/deck