Sha256: 4620273978e9cbfe88d6bf8e0d6a28501348e505144285f41ae4321c7184a9fe

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

#!/usr/bin/ruby -w
#
# * The standard input stream will be read if an input file is not specified.
#
# * The final output document will be written to the standard output stream.
#
# * If an error occurs, the input document will be written to the standard
#   output stream, so that you can investigate line numbers in the error.
#
# Usage:
#
#   erbook [Options] FormatName [InputFile]
#   erbook [Options] FormatFile [InputFile]
#

#--
# Copyright protects this work.
# See LICENSE file for details.
#++

require 'rubygems'
gem 'inochi', '~> 1'
require 'inochi'

options = Inochi.main :ERBook do
  # show list of available formats
  text 'FormatName:'

  require 'yaml'
  ERBook::FORMAT_FILES.each do |file|
    name = File.basename(file, '.yaml')
    desc = YAML.load_file(file)['desc'] rescue nil
    banner '%8s:  %s' % [name, desc]
  end
  text ''

  # show list of command-line options
  text 'Options:'
  opt :unindent, 'Unindent node content hierarchically'
end

format = ARGV.shift or
  raise ArgumentError, "Format was not specified.  Run `#{$0} -h` for help."

if input_file = ARGV.shift
  input_text = File.read(input_file)
else
  input_file = 'STDIN'
  input_text = STDIN.read
end

puts ERBook::Document.new(format, input_text, input_file, options)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
erbook-8.0.0 bin/erbook
erbook-7.3.0 bin/erbook
erbook-7.1.1 bin/erbook
erbook-7.1.0 bin/erbook