class Bundler::Audit::CLI

def check(dir=Dir.pwd)

def check(dir=Dir.pwd)
  unless File.directory?(dir)
    say_error "No such file or directory: #{dir}", :red
    exit 1
  end
  begin
    extend Formats.load(options[:format])
  rescue Formats::FormatNotFound
    say_error "Unknown format: #{options[:format]}", :red
    exit 1
  end
  if !Database.exists?(options[:database])
    download(options[:database])
  elsif options[:update]
    update(options[:database])
  end
  database = Database.new(options[:database])
  scanner  = begin
               Scanner.new(dir,options[:gemfile_lock],database, options[:config])
             rescue Bundler::GemfileLockNotFound => exception
               say exception.message, :red
               exit 1
             end
  report = scanner.report(ignore: options.ignore)
  output = if options[:output]
             File.new(options[:output],'w')
           else
             $stdout
           end
  print_report(report,output)
  output.close if options[:output]
  exit(1) if report.vulnerable?
end