Class: Lilac::CLI::Subcommand::Base
- Inherits:
-
Object
- Object
- Lilac::CLI::Subcommand::Base
- 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:
Class Method Summary collapse
-
.help_text ⇒ Object
lilac help <name>dispatcher uses this to render per-subcommand help.
Instance Method Summary collapse
-
#initialize(argv, out: $stdout, err: $stderr) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
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_text ⇒ Object
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
#run ⇒ Object
28 29 30 |
# File 'lib/lilac/cli/subcommand/base.rb', line 28 def run raise NotImplementedError end |