Sha256: 8d7604503461ff1b0130c414e7a03b9af47838742dae1eb87d30ff4f6cd10558

Contents?: true

Size: 775 Bytes

Versions: 4

Compression:

Stored size: 775 Bytes

Contents

require 'forwardable'
require_relative 'repo'
require_relative 'settings'
require_relative 'sig_from_stream'

module Signore
  class CLI
    extend Forwardable

    delegate %i(action tags) => :settings

    def initialize(args = ARGV, repo: Repo.new)
      @settings = Settings.new(args)
      @repo     = repo
    end

    def run(input: $stdin)
      case action
      when 'prego'  then puts retrieve_sig
      when 'pronto' then puts create_sig_from(input)
      else abort 'usage: signore prego|pronto [tag, …]'
      end
    end

    private_attr_reader :repo, :settings

    private

    def create_sig_from(input)
      SigFromStream.sig_from(input, tags: tags).tap { |sig| repo << sig }
    end

    def retrieve_sig
      repo.find(tags: tags)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
signore-0.4.2 lib/signore/cli.rb
signore-0.4.1 lib/signore/cli.rb
signore-0.4.0 lib/signore/cli.rb
signore-0.3.3 lib/signore/cli.rb