Sha256: d6277edf96e7501ce0fad3a4f6e620470ce9a17adf334b12e5ed8be97e7c451e

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

def usage
  puts "Usage: propaganda [options] input output" 
  puts ""
  puts "  --title=='A Friendly Title' (will detect from filename if omitted)"
  puts "  --template=={default|clean} (will use default if omitted)"
  puts "  --engine=={markdown|textile|none} (will detect from filename if omitted)"
  puts "  --html Output html"
  puts "  --pdf Output pdf (default)"
  puts "  --verbose Show errors and warnings"  
  puts "  --help"
  exit
end

usage if ARGV.size == 0 || ARGV.include?('--help')

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) if ENV['PROPAGANDA_ENV'] == 'test'

require 'rubygems'
require 'propaganda'

def opt(name)
  p = ARGV.select{|arg| arg =~ /^--#{name}/}.first
  p = p.gsub(/^--/, '') if p
  p = p.gsub(/^#{name}=/, '') if p
end

template = opt "template"
title = opt "title"
engine = opt "engine"
html = opt "html"
verbose = !opt("verbose").nil?

# Grab the params
params = ARGV.reject{|arg| arg =~ /^--/}
input = params[0] rescue nil
output = params[1] rescue nil
usage if input.nil? || output.nil?

# Run it
Propaganda.convert(input, output, title, template, engine, html, verbose)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
propaganda-0.5.0 bin/propaganda