Sha256: d8995c3261f0bd3574634fae5f59869fe3d83e64ab256011b6a4a68ed9f4b023

Contents?: true

Size: 787 Bytes

Versions: 6

Compression:

Stored size: 787 Bytes

Contents

module RuboCop
  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

        def initialize(argv)
          @argv = argv
        end

        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

        private def fail!(opt)
          puts opt.help
          exit 1
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-extension-generator-0.5.2 lib/rubocop/extension/generator/cli.rb
rubocop-extension-generator-0.5.1 lib/rubocop/extension/generator/cli.rb
rubocop-extension-generator-0.5.0 lib/rubocop/extension/generator/cli.rb
rubocop-extension-generator-0.4.0 lib/rubocop/extension/generator/cli.rb
rubocop-extension-generator-0.3.0 lib/rubocop/extension/generator/cli.rb
rubocop-extension-generator-0.2.3 lib/rubocop/extension/generator/cli.rb