Sha256: 2f231fcd3a8fe4d73ff8a53b5023a8fa7d54b46e0944b5b7a2b1a7c78f23c067

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 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]
#

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 '%8s:  %s' % [name, desc]
    end
    text ''

    # show list of command-line options
    text 'Options:'
    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

1 entries across 1 versions & 1 rubygems

Version Path
erbook-6.1.0 bin/erbook