Class: Sonar::CLI
- Inherits:
-
Thor
- Object
- Thor
- Sonar::CLI
- Defined in:
- lib/sonar/cli/cli.rb
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #profile ⇒ Object
- #search(type, term) ⇒ Object
- #types ⇒ Object
- #usage ⇒ Object
Constructor Details
Instance Method Details
#config ⇒ Object
58 59 60 61 |
# File 'lib/sonar/cli/cli.rb', line 58 def config # TODO: add a way to set config puts "Your config file is located at #{RCFile.instance.path}" end |
#profile ⇒ Object
18 19 20 |
# File 'lib/sonar/cli/cli.rb', line 18 def profile ap @config end |
#search(type, term) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sonar/cli/cli.rb', line 31 def search(type, term) @query = {} @query[type.to_sym] = term @query[:limit] = ['record_limit'] @query[:exact] = ['exact'] resp = @client.search(@query) errors = 0 if resp.is_a?(Sonar::Request::RequestIterator) resp.each do |data| errors += 1 if data.key?('errors') || data.key?('error') print_json(cleanup_data(data), ['format']) end else errors += 1 if resp.key?('errors') || resp.key?('error') print_json(cleanup_data(resp), ['format']) end raise Search::SearchError.new("Encountered #{errors} errors while searching") if errors > 0 end |
#types ⇒ Object
53 54 55 |
# File 'lib/sonar/cli/cli.rb', line 53 def types ap Search::QUERY_TYPES_MAP end |
#usage ⇒ Object
23 24 25 |
# File 'lib/sonar/cli/cli.rb', line 23 def usage ap @client.usage end |