Module: Lilac::CLI::Subcommand::OptionHelpers

Defined in:
lib/lilac/cli/subcommand/option_helpers.rb

Overview

Shared OptionParser option groups. build / dev / doctor / preview accept the same path-config flags; build / dev additionally accept the target / mrbc / runtime flags. Keeping these here so the subcommand classes don't drift out of sync.

Class Method Summary collapse

Class Method Details

.add_path_options(o, opts) ⇒ Object

The path-config flags build / dev / doctor / preview all accept. o.on mutates the OptionParser passed in; opts collects the parsed values for the caller's later Config.load merge.



19
20
21
22
23
24
25
# File 'lib/lilac/cli/subcommand/option_helpers.rb', line 19

def add_path_options(o, opts)
  o.on("--components DIR", "Components directory (default: components)") { |v| opts[:components] = v }
  o.on("--pages DIR", "Pages directory (default: pages)") { |v| opts[:pages] = v }
  o.on("--public DIR", "Static-passthrough directory (default: public)") { |v| opts[:public] = v }
  o.on("--output DIR", "-o DIR", "Output directory (default: dist)") { |v| opts[:output] = v }
  o.on("--root DIR", "Project root (default: cwd)") { |v| opts[:root] = v }
end

.add_target_options(o, opts) ⇒ Object

Build / dev target selection. --target full produces dist HTML with inline Ruby + lilac-full wasm (original Lilac story). --target compiled invokes mrbc to produce .mrb bytecode + lilac-compiled wasm (smaller production bundle, ~32% brotli). --mrbc-path lets the user pin a specific mrbc binary when the auto-discovery would pick the wrong one.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/lilac/cli/subcommand/option_helpers.rb', line 33

def add_target_options(o, opts)
  o.on("--target TARGET", Config::TARGET_VALUES.map(&:to_s),
       "Build target (#{Config::TARGET_VALUES.join(' / ')}; default: full)") do |v|
    opts[:target] = v.to_sym
  end
  o.on("--mrbc-path PATH",
       "Path to the mrbc binary (default: auto-discover)") do |v|
    opts[:mrbc_path] = v
  end
  o.on("--lilac-compiled-path PATH",
       "Path to lilac-compiled.wasm (default: auto-discover; --target compiled only)") do |v|
    opts[:lilac_compiled_path] = v
  end
  o.on("--lilac-full-path PATH",
       "Path to lilac-full.wasm (default: auto-discover; --target full only)") do |v|
    opts[:lilac_full_path] = v
  end
  o.on("--mruby-wasm-js-path PATH",
       "Path to the mruby-wasm-js bridge directory (default: auto-discover)") do |v|
    opts[:mruby_wasm_js_path] = v
  end
end