Sha256: f99e9bb2f0314d7b803e0fb219d6bc45d88ef57b9e4e9aa0e90098090779772b

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

require "sod"

module Pennyworth
  module CLI
    module Actions
      # Handles the Standard Gem action.
      class StandardGem < Sod::Action
        include Import[:io]

        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) = io.puts processor.call(endpoints.fetch(kind || default)).to_json

        private

        attr_reader :processor, :endpoints
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pennyworth-17.1.0 lib/pennyworth/cli/actions/standard_gem.rb
pennyworth-17.0.0 lib/pennyworth/cli/actions/standard_gem.rb