Sha256: 260dd71667833cafa709a3f7abcd593cc415a896a707272b0eb8bb8da94ab004

Contents?: true

Size: 1.99 KB

Versions: 8

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

require "dry/cli"
require "ostruct"

module Hanami
  # Hanami CLI
  #
  # @since 1.1.0
  class CLI
    # Register a command to expand Hanami CLI
    #
    # @param name [String] the command name
    # @param command [NilClass,Hanami::CLI::Command,Hanami::CLI::Commands::Command]
    #   the optional command
    # @param aliases [Array<String>] an optional list of aliases
    #
    # @since 1.1.0
    #
    # @example Third party gem
    #   require "hanami/cli/commands"
    #
    #   module Hanami
    #     module Webpack
    #       module CLI
    #         module Commands
    #           class Generate < Hanami::CLI::Command
    #             desc "Generate Webpack configuration"
    #
    #             def call(*)
    #               # ...
    #             end
    #           end
    #         end
    #       end
    #     end
    #   end
    #
    #   Hanami::CLI.register "generate webpack", Hanami::Webpack::CLI::Commands::Generate
    #
    #   # $ bundle exec hanami generate
    #   # Commands:
    #   #   hanami generate action APP ACTION                    # Generate an action for app
    #   #   hanami generate app APP                              # Generate an app
    #   #   hanami generate mailer MAILER                        # Generate a mailer
    #   #   hanami generate migration MIGRATION                  # Generate a migration
    #   #   hanami generate model MODEL                          # Generate a model
    #   #   hanami generate secret [APP]                         # Generate session secret
    #   #   hanami generate webpack                              # Generate Webpack configuration
    def self.register(name, command = nil, aliases: [], &blk)
      Commands.register(name, command, aliases: aliases, &blk)
    end

    # CLI commands registry
    #
    # @since 1.1.0
    # @api private
    module Commands
      extend Dry::CLI::Registry

      require "hanami/cli/commands/command"
      require "hanami/cli/commands/server"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hanami-2.0.0.alpha8 lib/hanami/cli/commands.rb
hanami-2.0.0.alpha7.1 lib/hanami/cli/commands.rb
hanami-2.0.0.alpha7 lib/hanami/cli/commands.rb
hanami-2.0.0.alpha6 lib/hanami/cli/commands.rb
hanami-2.0.0.alpha5 lib/hanami/cli/commands.rb
hanami-2.0.0.alpha4 lib/hanami/cli/commands.rb
hanami-2.0.0.alpha3 lib/hanami/cli/commands.rb
hanami-2.0.0.alpha2 lib/hanami/cli/commands.rb