Class: CustomCopsGenerator::CLI
- Inherits:
-
Object
- Object
- CustomCopsGenerator::CLI
- Defined in:
- lib/custom_cops_generator/cli.rb
Constant Summary collapse
- BANNER =
<<~TEXT Usage: custom_cops_generator NAME TEXT
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
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
#run ⇒ Object
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 |