Class: Boppers::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/boppers/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/boppers/cli.rb', line 7

def self.exit_on_failure?
  true
end

Instance Method Details

#app(name) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/boppers/cli.rb', line 57

def app(name)
  require "boppers/generator/app"

  base_path = File.expand_path(name)

  generator = Generator::App.new
  generator.destination_root = base_path
  generator.invoke_all
end

#plugin(name) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/boppers/cli.rb', line 36

def plugin(name)
  require "boppers/generator/plugin"

  unless %w[bopper notifier].include?(options[:type])
    message = "ERROR: --type needs to be either 'bopper' or 'notifier'"
    shell.error shell.set_color(message, :red)
    exit 1
  end

  suffix = "-notifier" if options[:type] == "notifier"
  base_path = File.dirname(File.expand_path(name))
  base_name = "boppers-#{File.basename(name)}#{suffix}"

  generator = Generator::Plugin.new
  generator.plugin_type = options[:type]
  generator.destination_root = File.join(base_path, base_name)
  generator.invoke_all
end

#setup(name) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/boppers/cli.rb', line 69

def setup(name)
  file = File.expand_path("../../setup/#{name}.rb", __dir__)

  unless File.file?(file)
    message = "ERROR: invalid setup name."
    shell.error shell.set_color(message, :red)
    exit 1
  end

  require file
  Setup.call(shell)
end

#startObject



18
19
20
21
# File 'lib/boppers/cli.rb', line 18

def start
  require options[:require]
  Runner.new.call
end

#versionObject



26
27
28
# File 'lib/boppers/cli.rb', line 26

def version
  say "Boppers v#{VERSION}"
end