Class: BoringBuilder::CLI
- Inherits:
-
Object
- Object
- BoringBuilder::CLI
- Defined in:
- lib/boringbuilder/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv, out: $stdout, err: $stderr, builder_class: Builder, environment: ENV) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(argv, out: $stdout, err: $stderr, builder_class: Builder, environment: ENV) ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 17 18 19 |
# File 'lib/boringbuilder/cli.rb', line 13 def initialize(argv, out: $stdout, err: $stderr, builder_class: Builder, environment: ENV) @argv = argv.dup @out = out @err = err @builder_class = builder_class @environment = environment end |
Class Method Details
.start(argv = ARGV) ⇒ Object
9 10 11 |
# File 'lib/boringbuilder/cli.rb', line 9 def self.start(argv = ARGV, **) new(argv, **).start end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/boringbuilder/cli.rb', line 21 def run return root_help if @argv.empty? || %w[help --help -h].include?(@argv.first) return version if %w[version --version -v].include?(@argv.first) command = @argv.shift case command when "build" then build when "doctor" then doctor when "init" then initialize_project else raise ConfigurationError, "Unknown command '#{command}'. Use build, doctor, init, or version." end end |
#start ⇒ Object
34 35 36 37 38 39 |
# File 'lib/boringbuilder/cli.rb', line 34 def start run rescue BoringBuilder::Error, OptionParser::ParseError => e @err.puts "boringbuilder: #{e.}" 1 end |