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
#initialize ⇒ CLI
Returns a new instance of CLI.
15 16 17 18 19 |
# File 'lib/sonar/cli/cli.rb', line 15 def initialize(*) @config = Sonar::RCFile.instance.load_file @client = Sonar::Client.new(email: @config["email"], access_token: @config["access_token"], api_url: @config["api_url"]) super end |
Instance Method Details
#config ⇒ Object
62 63 64 65 |
# File 'lib/sonar/cli/cli.rb', line 62 def config # TODO: add a way to set config puts "Your config file is located at #{RCFile.instance.path}" end |
#profile ⇒ Object
22 23 24 |
# File 'lib/sonar/cli/cli.rb', line 22 def profile ap @config end |
#search(type, term) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sonar/cli/cli.rb', line 34 def search(type, term) types = [type] if type == 'all' if term =~ IS_IP types = ip_search_type_names else types = domain_search_type_names end end types.each do |type| @query = {} @query[type.to_sym] = term @query[:limit] = ['record_limit'] @query[:exact] = ['exact'] resp = @client.search(@query) handle_search_response(resp) end end |
#types ⇒ Object
56 57 58 59 |
# File 'lib/sonar/cli/cli.rb', line 56 def types tp.set :io, $stdout tp QUERY_TYPES, :name, { description: { width: 100 } }, :input end |
#usage ⇒ Object
27 28 29 |
# File 'lib/sonar/cli/cli.rb', line 27 def usage ap @client.usage end |