Class: Beadme::Runner

Inherits:
Thor
  • Object
show all
Defined in:
lib/beadme/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



38
39
40
# File 'lib/beadme/runner.rb', line 38

def self.banner(command, _namespace = nil, _subcommand = false)
  "#{basename} #{command.usage}"
end

.exit_on_failure?Boolean

Returns:

  • (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.message
  exit 1
rescue Interrupt
  warn "\nAborted!"
  exit 1
end

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/beadme/runner.rb', line 11

def create
  say "#{Beadme.configuration.messages[:welcome]}\n"
  puts options[:output]

  Template.new(
    # update this line to use the new configuration
    # template: custom_template,
    # questions: custom_questions,
    dir: options[:output] || Dir.pwd
  ).create
end

#helpObject



32
33
34
35
36
# File 'lib/beadme/runner.rb', line 32

def help(*)
  say Beadme.configuration.messages[:about]
  say "\nVersion: #{VERSION}\n\n"
  super
end

#versionObject



27
28
29
# File 'lib/beadme/runner.rb', line 27

def version
  puts VERSION
end