Class: Dopstick::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/dopstick/cli.rb', line 8

def self.exit_on_failure?
  true
end

Instance Method Details

#new(path = nil) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/dopstick/cli.rb', line 68

def new(path = nil)
  interrupt_with_help(:new) if options[:help] || path.to_s.strip.empty?

  unless Generator.registered.include?(options[:type])
    interrupt_with_error(
      "--type must be one of #{Generator.registered.keys.inspect}"
    )
  end

  package_name, namespace = expand_gem_name_and_namespace(path)

  generator_module = Generator.registered[options[:type]]
  generator_class = generator_module.const_get(:Generator)
  options_class = generator_module.const_get(:Options)
  generator = generator_class.new
  generator.destination_root = File.expand_path(path)
  generator.options = options_class.new(
    dup_options.merge(
      package_name: package_name,
      namespace: namespace,
      entry_path: namespace.underscore("/")
    )
  )

  generator.invoke_all
end