Sha256: 8b9ab6310ac57c4b4815e2b379a5a9bc1ab96cab1adc7a62fb4f9c53e1ca0153
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# encoding: UTF-8 module Signore class Executable def initialize args = ARGV, db = Database opts = Trollop.options args do opt :database, 'Location of the signature database', default: (ENV['XDG_DATA_HOME'] or File.expand_path '~/.local/share') + '/signore/signatures.yml' end Trollop.die 'usage: signore prego|pronto [label, …]' unless ['prego', 'pronto'].include? args.first db.load opts[:database] @action = args.shift @no_tags, @tags = args.partition { |tag| tag[0] == '~' } @no_tags.map! { |tag| tag[1..-1] } end def run output = STDOUT, input = STDIN case @action when 'prego' output.puts Database.find(tags: @tags, no_tags: @no_tags).display when 'pronto' params = Hash[[:text, :author, :subject, :source].map do |elem| output.puts "#{elem}?" value = '' value << input.gets until value.lines.to_a.last == "\n" [elem, value.rstrip] end].delete_if { |elem, value| value.empty? } sig = Signature.new params[:text], params[:author], params[:source], params[:subject], @tags Database.save sig output.puts sig.display end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
signore-0.0.0 | lib/signore/executable.rb |