Class: CustomCopsGenerator::CLI

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

Constant Summary collapse

<<~TEXT
  Usage: custom_cops_generator NAME
TEXT

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



11
12
13
# File 'lib/custom_cops_generator/cli.rb', line 11

def initialize(argv)
  @argv = argv
end

Class Method Details

.run(argv) ⇒ Object



7
8
9
# File 'lib/custom_cops_generator/cli.rb', line 7

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

Instance Method Details

#runObject



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

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

  name = args.first
  raise "It must be named `rubocop-*`. For example: rubocop-rspec" unless name.match?(/\Arubocop-\w+\z/)

  Generator.new(name).generate
end