Class: RailsSteroids::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/rails_steroids/cli.rb', line 45

def self.exit_on_failure?
  true
end

Instance Method Details

#inject(generator, *options) ⇒ Object



12
13
14
15
# File 'lib/rails_steroids/cli.rb', line 12

def inject(generator, *options)
  require_relative generator_file_path(generator)
  Rails::Generators.invoke(generator, options)
end

#listObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rails_steroids/cli.rb', line 23

def list
  say "RailsSteroids list", [:bold, :cyan]
  steroid_names = [
    'migration',
    'model',
    'controller',
    'new_project',
  ]
  arr = [['Functionality', 'Command']]
  arr << ['===============', '================================================']
  steroid_names.each do |steroid|
    arr << [steroid.titlecase, "`rails_steroids inject steroid:#{steroid}`"]
  end
  print_table(arr, {borders: true})
  # TODO: Glob all file and prepare a list of available generators
end

#prepare(steroid) ⇒ Object



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

def prepare(steroid)
  Rails::Generators.invoke('steroid', [steroid])
end

#versionObject



41
42
43
# File 'lib/rails_steroids/cli.rb', line 41

def version
  puts "RailsSteroids v#{RailsSteroids::VERSION}"
end