Class: Rails::Command::HyperdriveCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/commands/hyperdrive/hyperdrive_command.rb

Overview

The generators are the sole authority on option parsing, defaults, and validation; this class only forwards argv and renders --help.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], local_options = {}, config = {}) ⇒ HyperdriveCommand

Thor treats a leading -- as an options terminator, so with -- --merge the flag lands in positional args and options[:merge] is false. Both spellings must reach the generator identically.



27
28
29
30
31
# File 'lib/rails/commands/hyperdrive/hyperdrive_command.rb', line 27

def initialize(args = [], local_options = {}, config = {})
  super
  @argv = args + (local_options.is_a?(Array) ? local_options : [])
  @argv = @argv.drop(1) if @argv.first == "--"
end

Class Method Details

.mirror_generator_options(klass) ⇒ Object

Mirrors a generator's own flags so the help surface cannot drift from what the generator actually accepts. Thor's runtime options are excluded: they are inherited plumbing, not part of this command.



17
18
19
20
21
22
# File 'lib/rails/commands/hyperdrive/hyperdrive_command.rb', line 17

def self.mirror_generator_options(klass)
  klass.class_options.each do |name, option|
    next if ::Rails::Generators::Base.class_options.key?(name)
    method_options[name] = option
  end
end

Instance Method Details

#discoverObject



47
48
49
# File 'lib/rails/commands/hyperdrive/hyperdrive_command.rb', line 47

def discover(*)
  start_generator("discover", "DiscoverGenerator")
end

#initObject



35
36
37
# File 'lib/rails/commands/hyperdrive/hyperdrive_command.rb', line 35

def init(*)
  start_generator("install", "InstallGenerator")
end

#syncObject



41
42
43
# File 'lib/rails/commands/hyperdrive/hyperdrive_command.rb', line 41

def sync(*)
  start_generator("sync", "SyncGenerator")
end