Class: Lilac::CLI::Subcommand::Base

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

Overview

Base for lilac <subcommand> handlers. Each subclass:

1. defines `opts_parser(opts)` returning an OptionParser whose
 callbacks populate `opts`
2. defines `run` returning the desired process exit status

Command instantiates the right subclass based on argv and delegates. Exception handling (turning Builder::Error etc. into "lilac: " + status 1) stays in Command's outer rescue so the error surface is uniform across subcommands.

Direct Known Subclasses

Build, Dev, Doctor, New, PackageBuild, Preview

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, out: $stdout, err: $stderr) ⇒ Base

Returns a new instance of Base.



22
23
24
25
26
# File 'lib/lilac/cli/subcommand/base.rb', line 22

def initialize(argv, out: $stdout, err: $stderr)
  @argv = argv
  @out = out
  @err = err
end

Class Method Details

.help_textObject

lilac help <name> dispatcher uses this to render per-subcommand help. Sink IO so the -h callback some opts_parser definitions bake in doesn't fire during help rendering.



35
36
37
38
# File 'lib/lilac/cli/subcommand/base.rb', line 35

def self.help_text
  sink = StringIO.new
  new([], out: sink, err: sink).send(:opts_parser, {}).to_s
end

Instance Method Details

#runObject

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/lilac/cli/subcommand/base.rb', line 28

def run
  raise NotImplementedError
end