Sha256: 33c72ef1b9124111198c3fd6577ea0714414f3da4da44d49a134406c82ed5cf0

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 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 [Option...] FormatName [InputFile]
#   erbook [Option...] FormatFile [InputFile]
#

require 'rubygems'
require 'inochi'

# command line
  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 '%16s:   %s' % [name, desc]
    end

    text ''

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

# program body
  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

2 entries across 2 versions & 1 rubygems

Version Path
erbook-6.0.1 bin/erbook
erbook-6.0.0 bin/erbook