Class: Librr::CmdParser
- Inherits:
-
Thor
- Object
- Thor
- Librr::CmdParser
- Defined in:
- lib/librr/cmd_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(dir) ⇒ Object
- #list ⇒ Object
- #reindex ⇒ Object
- #remove(dir) ⇒ Object
- #search(text) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Class Method Details
Instance Method Details
#add(dir) ⇒ Object
23 24 25 26 |
# File 'lib/librr/cmd_parser.rb', line 23 def add(dir) puts "indexing: #{dir}" @@client.cmd(:add, dir: File.(dir)) end |
#list ⇒ Object
35 36 37 |
# File 'lib/librr/cmd_parser.rb', line 35 def list puts @@client.cmd(:list) end |
#reindex ⇒ Object
40 41 42 |
# File 'lib/librr/cmd_parser.rb', line 40 def reindex @@client.cmd(:reindex) end |
#remove(dir) ⇒ Object
29 30 31 32 |
# File 'lib/librr/cmd_parser.rb', line 29 def remove(dir) puts "removing: #{dir}" @@client.cmd(:remove, dir: File.(dir)) end |
#search(text) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/librr/cmd_parser.rb', line 47 def search(text) puts "searching: #{text}" results = @@client.cmd(:search, text: text, all: [:all], rows: [:rows]) if results.empty? puts "find no result" else puts results.map{|v| v.join(":")} end end |
#start ⇒ Object
10 11 12 13 14 |
# File 'lib/librr/cmd_parser.rb', line 10 def start if @@client.check_start([:sync]) puts 'server already started..' end end |
#stop ⇒ Object
17 18 19 20 |
# File 'lib/librr/cmd_parser.rb', line 17 def stop puts 'stopping..' @@client.cmd(:stop) rescue nil end |