+ # Setup the logger
+ logger = DelayedLogger ()
+ logging.basicConfig (stream=logger, level=logging.WARNING, \
+ format='%(levelname)-8s %(message)s')
+
+ # Build the OptionParser
+ parser = optparse.OptionParser()
+ parser.add_option('-n', '--not-recursive',
+ action='store_false', dest='recursive',
+ default=config_get_value('options', 'recursive'),
+ help="Don't run recursively")
+
+ parser.add_option('-d', '--work-dir',
+ dest='work_dir', type='string',
+ default=config_get_value('directories', 'working_directory'),
+ help="Start running at DIR", metavar='DIR')
+
+ parser.add_option('-e', '--extract-dir',
+ dest='extract_dir', type='string',
+ default=config_get_value('directories', 'extract_directory'),
+ help="Extract to DIR", metavar='DIR')
+
+ parser.add_option('-p', '--check-required-programs',
+ action='store_true', dest='check_progs',
+ default=False,
+ help="Check for required programs")
+
+ parser.add_option('-f', '--write-default-config',
+ action='store_true', dest='write_def_config',
+ default=False, help="Write out a new default config")
+
+ parser.add_option('-c', '--write-new-config',
+ action='store_true', dest='write_config',
+ default=False, help="Write out the current config")
+
+ parser.add_option('-i', '--interactive', dest='interactive', action='store_true',
+ default=config_get_value('options', 'interactive'),
+ help="Confirm before removing files")
+
+ parser.add_option('-q', '--quiet', dest='quiet', action='count',
+ default=0, help="Output fatal messages only")
+
+ parser.add_option('-v', '--verbose', dest='verbose', action='count',
+ default=0, help="Output extra information")
+
+ parser.add_option('-V', '--version', dest='version', action='store_true',
+ default=False, help="Output version information")
+
+ parser.version = VERSION
+
+ # Parse the given options
+ global options
+ (RarslaveGlobals.options, args) = parser.parse_args()
+ options = RarslaveGlobals.options
+
+ # Run any special actions that are needed on these options
+ run_options (options)
+
+ # Find the loglevel using the options given
+ logging.getLogger().setLevel (find_loglevel (options))
+
+ # Run recursively
+ if options.recursive:
+ for (dir, subdirs, files) in os.walk (options.work_dir):
+ parsets = generate_all_parsets (dir)
+ for (p2dir, p2file) in parsets:
+ detector = RarslaveDetector.RarslaveDetector (p2dir, p2file)
+ ret = detector.runMatchingTypes ()
+
+ # Non-recursive
+ else:
+ parsets = generate_all_parsets (options.work_dir)
+ for (p2dir, p2file) in parsets:
+ detector = RarslaveDetector.RarslaveDetector (p2dir, p2file)
+ ret = detector.runMatchingTypes ()
+
+ # Print the results
+ if logger.size () > 0:
+ print 'Log\n' + '=' * 80
+ logger.close ()
+
+ # Done!
+ return 0