Sha256: 7c79e01863ebe689d7609e969bea7464b71192df7d37e058c22cc20d3b540095

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 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.commit(:users) { find name }
                  .either(method(:success), method(:failure))
          end

          private

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

          def failure message
            logger.error { message }
            kernel.abort
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
milestoner-17.0.0 lib/milestoner/cli/actions/cache/find.rb