Sha256: 6d8e82dfce7baad188522f8f6abb17d0395a79f9dc61afba8212d23ed351a912

Contents?: true

Size: 668 Bytes

Versions: 3

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

require "sod"

module Milestoner
  module CLI
    module Actions
      module Cache
        # Handles finding a user in the cache.
        class Find < Sod::Action
          include Import[:kernel, :logger, client: :cache]

          description "Find user."

          on %w[-f --find], argument: "NAME"

          def call name
            client.read(:users) { find name }
                  .either(method(:success), method(:failure))
          end

          private

          def success(user) = kernel.puts user.to_h.values.join(", ")

          def failure(message) = logger.abort message
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
milestoner-17.11.0 lib/milestoner/cli/actions/cache/find.rb
milestoner-17.10.0 lib/milestoner/cli/actions/cache/find.rb
milestoner-17.9.0 lib/milestoner/cli/actions/cache/find.rb