From: Tollef Fog Heen Date: Fri, 14 Jun 2013 22:51:57 +0000 (+0200) Subject: Fix up formatting of queries, list keys X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a86e35591fe666d1d22d517dbd83e5fe91619657;p=pwstore Fix up formatting of queries, list keys --- diff --git a/pws b/pws index f0d3cd1..1d222cb 100755 --- a/pws +++ b/pws @@ -710,7 +710,7 @@ class Get io.puts parser.summarize io.puts "Decrypts the file, fetches a key and outputs it to stdout." io.puts "The file must be in YAML format." - io.puts "query is a query, formatted like host/users/root" + io.puts "query is a query, formatted like /host/users/root" exit(code) end @@ -730,8 +730,16 @@ class Get require 'pp' - a = what.split("/") + a = what.split("/")[1..-1] hit = yaml + if a.nil? + # q = /, so print top level keys + puts "Keys:" + hit.keys.each do |k| + puts "- #{k}" + end + return + end a.each do |k| hit = hit[k] end @@ -739,7 +747,9 @@ class Get STDERR.puts("No such key or invalid lookup expression") elsif hit.respond_to?(:keys) puts "Keys:" - puts hit.keys.join("\n") + hit.keys.each do |k| + puts "- #{k}" + end else puts hit end