Sha256: dcfc2311c96625194221a5d66a98b282c4ed2d343a8ba1900af3d21f60228ff5

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby

require 'optparse'

require 'markdown_helper'

options = {:pristine => false}

# Save opts for use below.
opts = nil
parser = OptionParser.new do |_opts|
  opts = _opts
  _opts.banner = "Usage: #{File.basename(__FILE__)} [options] template_file_path markdown_file_page"
  _opts.on('--pristine', 'No comments added') do |_|
    options[:pristine] = true
  end
  _opts.on('--help', 'Display help') do
    usage(_opts)
  end
end

def usage(opts)
  puts ''
  puts opts
  puts <<-EOT
    
  where

    * template_file_path is the path to an existing file.
    * markdown_file_path is the path to a file to be created.

  Typically:

    * Both file types are .md.
    * The template file contains file inclusion descriptions.
EOT
  exit
end

parser.parse!

template_file_path, markdown_file_path = ARGV

usage(opts) unless ARGV.size == 2
usage(opts) unless File.readable?(template_file_path)
usage(opts) unless File.writable?(File.dirname(markdown_file_path))

# This code, outside of a class, had interference from Module#include.
# So now it's in a class.
class AvoidModule
  def initialize(template_file_path, markdown_file_path, options)
    markdown_helper = MarkdownHelper.new(options)
    markdown_helper.include(template_file_path, markdown_file_path)
  end
end

AvoidModule.new(template_file_path, markdown_file_path, options)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
markdown_helper-1.5.1 bin/include
markdown_helper-1.5.0 bin/include