Class: Ronin::UI::CLI::Commands::Campaigns
- Inherits:
-
ResourcesCommand
- Object
- Thor::Group
- Ronin::UI::CLI::Command
- ModelCommand
- ResourcesCommand
- Ronin::UI::CLI::Commands::Campaigns
- Defined in:
- lib/ronin/ui/cli/commands/campaigns.rb
Overview
The ronin-campaigns
command.
Instance Method Summary collapse
-
#add(name) ⇒ Object
protected
Adds a new campaign.
-
#execute ⇒ Object
Queries the Campaign model.
-
#print_resource(campaign) ⇒ Object
protected
Prints a campaign.
Methods inherited from ResourcesCommand
Methods inherited from ModelCommand
each_query_option, model, #query, query_option, query_options, #setup
Methods inherited from Ronin::UI::CLI::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
Instance Method Details
#add(name) ⇒ Object (protected)
Adds a new campaign.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ronin/ui/cli/commands/campaigns.rb', line 81 def add(name) campaign = Campaign.new(:name => name) # add targets to the campaign [:targets].each { |target| campaign.target!(target) } if campaign.save print_info "Added campaign #{campaign}" else print_error "Could not add campaign #{name.dump}." end end |
#execute ⇒ Object
Queries the Campaign model.
63 64 65 66 67 68 69 |
# File 'lib/ronin/ui/cli/commands/campaigns.rb', line 63 def execute if [:add] add [:add] elsif .list? super end end |
#print_resource(campaign) ⇒ Object (protected)
Prints a campaign.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ronin/ui/cli/commands/campaigns.rb', line 102 def print_resource(campaign) return super(campaign) unless .verbose? print_title campaign.name indent do if campaign.description print_section 'Description' do campaign.description.each_line do |line| puts line end end end unless campaign.organizations.empty? print_array campaign.organizations, :title => 'Targeted Organizations' end unless campaign.targets.empty? print_array campaign.targets, :title => 'Targets' end end end |