Sha256: 92e6b71e225926afe42c9bce84f32be8f4bebeaf73409131be6a7ef0c1cd1db2

Contents?: true

Size: 913 Bytes

Versions: 4

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true

require "sod"

module Pennyworth
  module CLI
    module Actions
      # Handles the Standard Gems action.
      class StandardGems < Sod::Action
        include Import[:kernel]

        ENDPOINTS = {
          "all" => "stdgems.json",
          "default" => "default_gems.json",
          "bundled" => "bundled_gems.json"
        }.freeze

        description "Render Alfred Standard Gems script filter."

        on "--standard_gems", argument: "[KIND]", allow: %w[all default bundled], default: "all"

        def initialize(processor: Processor.for_standard_gems, endpoints: ENDPOINTS, **)
          super(**)
          @processor = processor
          @endpoints = endpoints
        end

        def call(kind = nil) = kernel.puts processor.call(endpoints.fetch(kind || default)).to_json

        private

        attr_reader :processor, :endpoints
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pennyworth-15.4.1 lib/pennyworth/cli/actions/standard_gems.rb
pennyworth-15.4.0 lib/pennyworth/cli/actions/standard_gems.rb
pennyworth-15.3.0 lib/pennyworth/cli/actions/standard_gems.rb
pennyworth-15.2.0 lib/pennyworth/cli/actions/standard_gems.rb