Sha256: 2cc10c41d2cb38208ef3de9f95b1378a68995f280809e15a3c3e0ee78af42871

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require "hanami/utils/deprecation"

module Hanami
  # General purpose Command Line Interface (CLI) framework for Ruby
  #
  # @since 0.1.0
  class CLI
    # @since 0.2.0
    class Error < StandardError
    end

    # @since 0.2.1
    class UnknownCommandError < Error
      # @since 0.2.1
      # @api private
      def initialize(command_name)
        super("unknown command: `#{command_name}'")
      end
    end

    # @since 0.2.0
    class InvalidCallbackError < Error
      # @since 0.2.0
      # @api private
      def initialize(callback)
        message = case callback
                  when Class
                    "expected `#{callback.inspect}' to respond to `#initialize' with arity 0"
                  else
                    "expected `#{callback.inspect}' to respond to `#call'"
                  end

        super(message)
      end
    end

    # @since 0.2.1
    def self.const_missing(name)
      super unless name == :UnkwnownCommandError
      Hanami::Utils::Deprecation.new('UnkwnownCommandError is deprecated, please use UnknownCommandError')
      UnknownCommandError
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hanami-cli-0.3.1 lib/hanami/cli/errors.rb
hanami-cli-0.3.0 lib/hanami/cli/errors.rb
hanami-cli-0.3.0.beta1 lib/hanami/cli/errors.rb