lib/signore/cli.rb in signore-0.4.2 vs lib/signore/cli.rb in signore-0.5.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'forwardable' require_relative 'repo' require_relative 'settings' require_relative 'sig_from_stream' @@ -14,24 +16,29 @@ @repo = repo end def run(input: $stdin) case action - when 'prego' then puts retrieve_sig + when 'prego' then prego 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 } + attr_reader :repo, :settings + + def prego + sig = repo.find(tags: tags) + puts case + when repo.empty? then 'No signatures found.' + when sig.empty? then "Sadly no signatures are tagged #{tags}." + else sig + end end - def retrieve_sig - repo.find(tags: tags) + def create_sig_from(input) + SigFromStream.sig_from(input, tags: tags).tap { |sig| repo << sig } end end end