Class: SecurityPentestPlanner::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/security_pentest_planner/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(argv = ARGV) ⇒ Object



9
10
11
# File 'lib/security_pentest_planner/cli.rb', line 9

def self.run(argv = ARGV)
  new.run(argv)
end

Instance Method Details

#run(argv) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/security_pentest_planner/cli.rb', line 13

def run(argv)
  options = default_options
  parser = build_option_parser(options)
  parser.parse!(argv)

  input = argv.first
  abort parser.help if input.nil?

  plan = SecurityPentestPlanner.generate(
    input_path: input,
    **options
  )

  if options[:output]
    File.write(options[:output], plan)
    warn "Plano de Ação gerado em #{options[:output]}"
  else
    puts plan
  end
rescue Error => e
  warn "Erro: #{e.message}"
  exit 1
end