Sha256: 340baa37477c3fb5cfaa6bacab54f046f2bc80e48e075447ec6840eda8c9019a

Contents?: true

Size: 765 Bytes

Versions: 9

Compression:

Stored size: 765 Bytes

Contents

# frozen_string_literal: true

require "rubycritic/command_factory"

module Skunk
  module Cli
    # Knows how to calculate the command that was request by the CLI user
    class CommandFactory < RubyCritic::CommandFactory
      COMMAND_CLASS_MODES = %i[version help default compare].freeze

      # Returns the command class based on the command that was executed
      #
      # @param mode
      # @return [Class]
      def self.command_class(mode)
        mode = mode.to_s.split("_").first.to_sym
        if COMMAND_CLASS_MODES.include? mode
          require "skunk/cli/commands/#{mode}"
          Command.const_get(mode.capitalize)
        else
          require "skunk/cli/commands/default"
          Command::Default
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
skunk-0.5.2 lib/skunk/cli/command_factory.rb
skunk-0.5.1 lib/skunk/cli/command_factory.rb
skunk-0.5.0 lib/skunk/cli/command_factory.rb
skunk-0.4.2 lib/skunk/cli/command_factory.rb
skunk-0.4.1 lib/skunk/cli/command_factory.rb
skunk-0.4.0 lib/skunk/cli/command_factory.rb
skunk-0.3.2 lib/skunk/cli/command_factory.rb
skunk-0.3.1 lib/skunk/cli/command_factory.rb
skunk-0.3.0 lib/skunk/cli/command_factory.rb