Module: LintFu::CLI

Defined in:
lib/lint_fu/cli.rb,
lib/lint_fu/cli/scan.rb,
lib/lint_fu/cli/prune.rb,
lib/lint_fu/cli/command.rb

Defined Under Namespace

Classes: Command, Prune, Scan

Constant Summary collapse

<<EOS
Lint-fu finds security defects in Ruby code.

Usage:
       lint_fu [options]
where [options] are:
EOS

Class Method Summary collapse

Class Method Details

.runObject



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

def self.run
  commands = []
  ObjectSpace.each_object(Class) do |c|
    commands << c.to_s.underscore if c.superclass == Command
  end

  opts = Trollop::options do
    version "Lint-Fu #{Gem.loaded_specs['lint_fu'].version} (c) 2011 Tony Spataro"
    banner BANNER
    stop_on commands
  end

  cmd_name = ARGV.shift || 'scan'
  sym = cmd_name.camelize.to_sym

  begin
    klass = const_get(sym)
    raise NameError unless klass.superclass == Command
  rescue NameError => e
    Trollop::die "Unknown command #{cmd_name}"
  end

  cmd = klass.new(opts)
  return cmd.run
rescue Interrupt => e
  say "Interrupt; exiting without completing task."
  exit(-1)
end

.say(*args) ⇒ Object



39
40
41
# File 'lib/lint_fu/cli.rb', line 39

def self.say(*args)
  puts(*args)
end