Class: RuboCop::Extension::Generator::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/extension/generator/cli.rb

Constant Summary collapse

<<~TEXT
  Usage: rubocop-extension-generator NAME

  The NAME must start with rubocop-, like rubocop-rspec.
TEXT

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



15
16
17
# File 'lib/rubocop/extension/generator/cli.rb', line 15

def initialize(argv)
  @argv = argv
end

Class Method Details

.run(argv) ⇒ Object



11
12
13
# File 'lib/rubocop/extension/generator/cli.rb', line 11

def self.run(argv)
  new(argv).run
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubocop/extension/generator/cli.rb', line 19

def run
  # For --help
  opt = OptionParser.new(BANNER)
  opt.version = VERSION
  args = opt.parse(@argv)

  name = args.first
  fail!(opt) unless name
  fail!(opt) unless name.match?(/\Arubocop-\w+\z/)

  Generator.new(name).generate
end