Sha256: ebee4f85533b32b02aeb4d086c96ca72aff4ce1aefbd97f2dc562c710a48bbf4
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true require "optparse" require "rerb" require "rerb/templater" module RERB # Command Line Interface for invoking RERB module CLI def parse(args) parser = OptionParser.new do |o| o.banner = "Usage: werb [options...] FILE" o.on( "--template TYPE", ["umd", "iife", "nil"], "Specify which html template to use to wrap the generated code. " \ "Valid options are umd, iife, and nil.", "nil will use no template and just output raw ruby.wasm code. " \ "Defaults to umd", ) o.on( "--root NAME", "The html id of the root element to add all other DOM nodes to. " \ 'Defaults to "root"', ) o.on("-v", "--version", "Output version information and exit.") end opts = { template: "umd", document: "document", root: "root", el_prefix: "el", } parser.parse!(args, into: opts) filename = args.shift return puts parser.help if filename.nil? input = File.read(filename) case opts[:template] when "umd" res = UMDTemplater.new(filename, opts[:root]) .generate(input) when "iife" res = IIFETemplater.new(filename, opts[:root]) .generate(input) when "nil" res = Templater.new(filename, opts[:root]) .generate(input) else raise "Invalid template option. Choose between umd, iife, nil." end puts res end module_function :parse end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rerb-0.1.1 | lib/rerb/cli.rb |