Sha256: cc797567cfb44bcf1193b604981020b4c80b8c8ffdbe9e4b34ad921e7ca8bc57

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

#!/usr/bin/env ruby
#
#  Created by Gregor Schmidt on 2007-9-30.
#  Copyright (c) 2007. All rights reserved.

begin
  require 'rubygems'
rescue LoadError
  # no rubygems to load, so we fail silently
end

require 'optparse'

OPTIONS = {
  :output_path     => nil
}
MANDATORY_OPTIONS = %w(  )

parser = OptionParser.new do |opts|
  opts.banner = <<BANNER
Literate Maruku allows you to interleave your documentation and the 
corresponding code in a style of literate programming. This is the
command line front end of the literate_maruku gem. You may find 
additional information on our website 

http://github.com/schmidt/literate_maruku/

Usage: #{File.basename($0)} [options] filename.mkd

Options are:
BANNER
  opts.separator ""
  opts.on("-o", "--output_path=PATH", String,
          "The root path for the generated files",
          "If not set, not output will be generated") { |OPTIONS[:output_path]| }
  opts.on("-h", "--help",
          "Show this help message.") { puts opts; exit }
  opts.parse!(ARGV)

  if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? } or ARGV[0].nil?
    puts opts; exit
  end
end

# do stuff
begin
  gem "literate_maruku"
  require "literate_maruku"
rescue LoadError
  require File.dirname(__FILE__) + "/../lib/literate_maruku"
end
require "pathname"

if OPTIONS[:output_path]
  if Pathname(OPTIONS[:output_path]).absolute?
    path = OPTIONS[:output_path]
  else
    path = File.join(Dir.pwd, OPTIONS[:output_path])
  end
  puts "Generating output to \"#{OPTIONS[:output_path]}\""
  LiterateMaruku.require(ARGV[0], :output => path)
else
  LiterateMaruku.require(ARGV[0])
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
literate_maruku-0.2.0 bin/literate_maruku
literate_maruku-0.1.3 bin/literate_maruku