Class: Jenerator::CLI

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/jenerator/cli.rb

Instance Method Summary collapse

Instance Method Details

#setupObject

Loads the components available for all generators.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jenerator/cli.rb', line 12

def setup
  Jenerator::Generators.load_components!

  generator_kind  = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0].present?
  generator_class = Jenerator::Generators.mappings[generator_kind]

  if generator_class
    args = ARGV.empty? && generator_class.require_arguments? ? ["-h"] : ARGV
    generator_class.start(args)
  else
    puts "Please specify generator to use (#{Jenerator::Generators.mappings.keys.join(", ")})"
  end
end