Class: Lilac::CLI::Subcommand::PackageBuild

Inherits:
Base
  • Object
show all
Defined in:
lib/lilac/cli/subcommand/package_build.rb

Instance Method Summary collapse

Methods inherited from Base

help_text, #initialize

Constructor Details

This class inherits a constructor from Lilac::CLI::Subcommand::Base

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lilac/cli/subcommand/package_build.rb', line 10

def run
  opts = parse_opts

  if opts[:output].nil?
    @err.puts "Usage: lilac package-build <input.rb>... -o <output.mrb>"
    return 1
  end
  if @argv.empty?
    @err.puts "lilac package-build: at least one input file required"
    @err.puts "Usage: lilac package-build <input.rb>... -o <output.mrb>"
    return 1
  end

  # Fully qualify the outer engine class to disambiguate from
  # the enclosing `Subcommand::PackageBuild` we're inside.
  package = ::Lilac::CLI::PackageBuild.new(
    inputs: @argv.dup,
    output: opts[:output],
    mrbc_path: opts[:mrbc_path],
  )
  out_path = package.run
  @out.puts "Built package bytecode: #{relative(out_path)} (#{File.size(out_path)} bytes)"
  0
end