Class: Opmac2html::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/opmac2html/cli.rb

Overview

Command line option parser and runner

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



8
9
10
11
12
13
14
15
16
17
# File 'lib/opmac2html/cli.rb', line 8

def initialize
  opts = Slop.parse(help: true) do |o|
    o.banner = 'Usage: opmac2html -i <input.tex> -o <output.html>'
    o.string '-i', '--input', 'Input OPmac file'
    o.string '-o', '--output', 'Output HTML file'
    o.on '-h', '--help', 'Shows this message'
    o.on '-v', '--version', 'Shows application version'
  end
  run opts
end

Instance Method Details

#run(opts) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/opmac2html/cli.rb', line 19

def run(opts)
  puts "opmac2html, version: #{Opmac2html.version}" if opts[:version]
  if opts[:input] && opts[:output]
    Converter.new(opts[:input], opts[:output]).convert
  else
    puts opts
  end
end