Class: Beadme::Runner
- Inherits:
-
Thor
- Object
- Thor
- Beadme::Runner
- Defined in:
- lib/beadme/runner.rb
Class Method Summary collapse
- .banner(command, _namespace = nil, _subcommand = false) ⇒ Object
- .exit_on_failure? ⇒ Boolean
- .start(args = ARGV, config = {}) ⇒ Object
Instance Method Summary collapse
Class Method Details
.banner(command, _namespace = nil, _subcommand = false) ⇒ Object
38 39 40 |
# File 'lib/beadme/runner.rb', line 38 def self.(command, _namespace = nil, _subcommand = false) "#{basename} #{command.usage}" end |
.exit_on_failure? ⇒ Boolean
59 60 61 |
# File 'lib/beadme/runner.rb', line 59 def self.exit_on_failure? true end |
.start(args = ARGV, config = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/beadme/runner.rb', line 42 def self.start(args = ARGV, config = {}) # I don't want to use commands like `beadme help` or `beadme version` # I want to use `beadme -h` or `beadme -v` instead # So I need to filter out the commands filter_commands = public_instance_methods(false).map(&:to_s) invalids = filter_commands & args raise UndefinedCommandError.new(invalids.first, [], nil) if invalids.any? super rescue Thor::Error => e warn e. exit 1 rescue Interrupt warn "\nAborted!" exit 1 end |
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/beadme/runner.rb', line 11 def create say "#{Beadme.configuration.[:welcome]}\n" puts [:output] Template.new( # update this line to use the new configuration # template: custom_template, # questions: custom_questions, dir: [:output] || Dir.pwd ).create end |
#help ⇒ Object
32 33 34 35 36 |
# File 'lib/beadme/runner.rb', line 32 def help(*) say Beadme.configuration.[:about] say "\nVersion: #{VERSION}\n\n" super end |
#version ⇒ Object
27 28 29 |
# File 'lib/beadme/runner.rb', line 27 def version puts VERSION end |