Class: Ronin::UI::CLI::ResourcesCommand
- Inherits:
-
ModelCommand
- Object
- Thor::Group
- Command
- ModelCommand
- Ronin::UI::CLI::ResourcesCommand
- Defined in:
- lib/ronin/ui/cli/resources_command.rb
Overview
A base-command class for listing Database Resources.
Direct Known Subclasses
Commands::Campaigns, Commands::Creds, Commands::Emails, Commands::Hosts, Commands::IPs, Commands::URLs
Class Method Summary collapse
-
.model(model = nil) ⇒ Object
protected
Sets the model used by the command.
Instance Method Summary collapse
-
#execute ⇒ Object
Default method performs the query and prints the found resources.
-
#print_resource(resource) ⇒ Object
protected
Default method which will print every queried resource.
-
#print_resources(resources) ⇒ Object
protected
Prints multiple resources.
Methods inherited from ModelCommand
each_query_option, #query, query_option, query_options, #setup
Methods inherited from Command
banner, command_name, #indent, inherited, #initialize, #print_array, #print_exception, #print_hash, #print_section, #print_title, #puts, run, #setup
Constructor Details
This class inherits a constructor from Ronin::UI::CLI::Command
Class Method Details
.model(model = nil) ⇒ Object (protected)
Sets the model used by the command.
62 63 64 65 66 67 68 69 70 |
# File 'lib/ronin/ui/cli/resources_command.rb', line 62 def self.model(model=nil) if (model && model < Model::Importable) class_option :import, :type => :string, :aliases => '-i', :banner => 'FILE' end return super(model) end |
Instance Method Details
#execute ⇒ Object
Default method performs the query and prints the found resources.
43 44 45 46 47 48 49 50 51 |
# File 'lib/ronin/ui/cli/resources_command.rb', line 43 def execute if [:import] self.class.model.import([:import]) do |resource| print_info "Imported #{resource}" end else print_resources(query) end end |
#print_resource(resource) ⇒ Object (protected)
Default method which will print every queried resource.
82 83 84 |
# File 'lib/ronin/ui/cli/resources_command.rb', line 82 def print_resource(resource) puts resource end |
#print_resources(resources) ⇒ Object (protected)
Prints multiple resources.
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ronin/ui/cli/resources_command.rb', line 96 def print_resources(resources) if .csv? print resources.to_csv elsif .xml? print resources.to_xml elsif .yaml? print resources.to_yaml elsif .json? print resources.to_json else resources.each { |resource| print_resource(resource) } end end |