Class: ShowWish
- Inherits:
-
Djinni::Wish
- Object
- Djinni::Wish
- ShowWish
- Defined in:
- lib/rubeepass/wish/show_wish.rb
Instance Method Summary collapse
- #aliases ⇒ Object
- #description ⇒ Object
- #execute(args, djinni_env = Hash.new) ⇒ Object
- #tab_complete(input, djinni_env = Hash.new) ⇒ Object
- #usage ⇒ Object
Instance Method Details
#aliases ⇒ Object
4 5 6 |
# File 'lib/rubeepass/wish/show_wish.rb', line 4 def aliases return ["cat", "show", "showall"] end |
#description ⇒ Object
8 9 10 11 12 |
# File 'lib/rubeepass/wish/show_wish.rb', line 8 def description return [ "Show group/entry contents (showall includes passwords)" ].join(" ") end |
#execute(args, djinni_env = Hash.new) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rubeepass/wish/show_wish.rb', line 14 def execute(args, djinni_env = Hash.new) keepass = djinni_env["keepass"] cwd = djinni_env["cwd"] args = cwd.path if (args.empty?) path = keepass.absolute_path(args, cwd.path) path, _, target = path.rpartition("/") new_cwd = keepass.find_group_like(path) if (new_cwd.nil?) puts "Group not found" return end if (target.empty?) case djinni_env["djinni_input"] when "showall" puts new_cwd.details(0, true) else puts new_cwd end elsif (new_cwd.has_group_like?(target)) new_cwd.groups_by_name(target, true).each do |group| case djinni_env["djinni_input"] when "showall" puts group.details(0, true) else puts group end end elsif (new_cwd.has_entry_like?(target)) new_cwd.entries_by_title(target, true).each do |entry| case djinni_env["djinni_input"] when "showall" puts entry.details(0, true) else puts entry end end else puts "Group/Entry not found" end end |
#tab_complete(input, djinni_env = Hash.new) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rubeepass/wish/show_wish.rb', line 58 def tab_complete(input, djinni_env = Hash.new) cwd = djinni_env["cwd"] groups, entries = cwd.fuzzy_find(input) completions = Hash.new groups.each do |group| completions[group] = "Group" end entries.each do |entry| completions[entry] = "Entry" end append = "/" append = "" if (groups.empty?) return [completions, input.rpartition("/")[-1], append] end |
#usage ⇒ Object
76 77 78 79 |
# File 'lib/rubeepass/wish/show_wish.rb', line 76 def usage puts "#{aliases.join(", ")} [group|entry]" puts " #{description}." end |