Class: Squill::CLIClient
- Inherits:
-
Thor
- Object
- Thor
- Squill::CLIClient
- Includes:
- Thor::Actions
- Defined in:
- lib/squill/cli.rb
Instance Method Summary collapse
- #add(name, file = nil) ⇒ Object
- #delete(name) ⇒ Object
- #list ⇒ Object
- #print(name) ⇒ Object
- #search(search_string) ⇒ Object
Instance Method Details
#add(name, file = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/squill/cli.rb', line 31 def add(name, file=nil) squill_file = Squill::SquillFile.new(name) if squill_file.exists_as_squill_file? && ![:replace] puts "\na squill by this name already exists. use the the --replace option to replace it.\n" return end squill_file.description = [:desc].nil? ? ask("Briefly describe #{name}: ") : [:desc] if file.nil? squill_file.set_sql else squill_file.set_sql_from_file(file) end squill_file.save puts "\nsaved squill #{name}.\n" end |
#delete(name) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/squill/cli.rb', line 92 def delete(name) squill_file = Squill::SquillFile.new(name) if squill_file.exists_as_squill_file? if yes?("are you sure you want to delete #{name}?") squill_file.delete puts "\nsquill #{name} deleted.\n" end else puts "\ncould not find squill named #{name} to delete.\n" end end |
#list ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/squill/cli.rb', line 113 def list searcher = Squill::SquillFileSearcher.new results = searcher.list results.each { |result| puts "#{result.name} - #{result.description}" } puts "\nlisted #{results.length} squills.\n" end |
#print(name) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/squill/cli.rb', line 57 def print(name) squill_file = Squill::SquillFile.new(name) if squill_file.exists_as_squill_file? puts squill_file.sql end end |
#search(search_string) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/squill/cli.rb', line 74 def search(search_string) searcher = Squill::SquillFileSearcher.new results = searcher.search(search_string) results.each { |result| puts "#{result[:name_highlight]} - #{result[:description_highlight]}" } puts "\nfound #{results.length} squills.\n" end |