lib/rubocop/extension/generator/cli.rb in rubocop-extension-generator-0.2.2 vs lib/rubocop/extension/generator/cli.rb in rubocop-extension-generator-0.2.3

- old
+ new

@@ -2,10 +2,12 @@ module Extension module Generator class CLI BANNER = <<~TEXT Usage: rubocop-extension-generator NAME + + The NAME must start with rubocop-, like rubocop-rspec. TEXT def self.run(argv) new(argv).run end @@ -15,15 +17,22 @@ end def run # For --help opt = OptionParser.new(BANNER) + opt.version = VERSION args = opt.parse(@argv) name = args.first - raise "It must be named `rubocop-*`. For example: rubocop-rspec" unless name.match?(/\Arubocop-\w+\z/) + fail!(opt) unless name + fail!(opt) unless name.match?(/\Arubocop-\w+\z/) Generator.new(name).generate + end + + private def fail!(opt) + puts opt.help + exit 1 end end end end end