Sha256: 0274f34820ab2cf0e0ddfa58cc696416ab2d07fb49f805fccb43902987dccba9

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "dry/inflector"
require "dry/files"
require "shellwords"
require_relative "../../../naming"
require_relative "../../../errors"

module Hanami
  module CLI
    module Commands
      module App
        module Generate
          # @since 2.2.0
          # @api private
          class Repo < Command
            argument :name, required: true, desc: "Repo name"

            example [
              %(books               (MyApp::Repos::BooksRepo)),
              %(books/drafts_repo   (MyApp::Repos::Books::DraftsRepo)),
              %(books --slice=admin (Admin::Repos::BooksRepo)),
            ]

            # @since 2.2.0
            # @api private
            def generator_class
              Generators::App::Repo
            end

            # @since 2.2.0
            # @api private
            def call(name:, **opts)
              name = "#{inflector.singularize(name)}_repo" unless name.end_with?("_repo")
              super
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hanami-cli-2.2.1 lib/hanami/cli/commands/app/generate/repo.rb
hanami-cli-2.2.0 lib/hanami/cli/commands/app/generate/repo.rb
hanami-cli-2.2.0.rc1 lib/hanami/cli/commands/app/generate/repo.rb
hanami-cli-2.2.0.beta2 lib/hanami/cli/commands/app/generate/repo.rb