Class: Passdb::CLI
- Inherits:
-
Thor
- Object
- Thor
- Passdb::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/passdb/cli.rb
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #search ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
11 12 13 14 |
# File 'lib/passdb/cli.rb', line 11 def initialize(*) super Thor::Shell::Basic.new end |
Instance Method Details
#search ⇒ Object
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 |
# File 'lib/passdb/cli.rb', line 21 def search opts = .dup if opts["vendor"] && opts["criteria"] puts "You can't specify both a vendor and a free-form criteria" exit 1 end if !(opts["vendor"] || opts["criteria"]) puts "You need to specify either --vendor or --criteria" exit 1 end results = nil if opts["vendor"] results = Passdb.search(:vendor => opts["vendor"]) else results = Passdb.search(:criteria => opts["criteria"]) end puts "#{results.size} entries were found:" results.each do |entry| puts " #{entry.name}" entry.attributes.each do |name, value| puts " #{name} => #{value}" end end end |