Sha256: 121355ac179562572d9c86c8d1ef85a379cf0dd5322a2fe8d1ec03ae1e66419b

Contents?: true

Size: 670 Bytes

Versions: 6

Compression:

Stored size: 670 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.abort message
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
milestoner-17.6.0 lib/milestoner/cli/actions/cache/find.rb
milestoner-17.5.0 lib/milestoner/cli/actions/cache/find.rb
milestoner-17.4.0 lib/milestoner/cli/actions/cache/find.rb
milestoner-17.3.0 lib/milestoner/cli/actions/cache/find.rb
milestoner-17.2.0 lib/milestoner/cli/actions/cache/find.rb
milestoner-17.1.0 lib/milestoner/cli/actions/cache/find.rb