[javascriptlint-commit] SF.net SVN: javascriptlint:[298] trunk/javascriptlint
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2010-04-23 20:38:12
|
Revision: 298 http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=298&view=rev Author: matthiasmiller Date: 2010-04-23 20:38:04 +0000 (Fri, 23 Apr 2010) Log Message: ----------- Add options to control whether to show header, file listings, and lint summary. Modified Paths: -------------- trunk/javascriptlint/jsl.py trunk/javascriptlint/lint.py Modified: trunk/javascriptlint/jsl.py =================================================================== --- trunk/javascriptlint/jsl.py 2010-04-23 20:09:47 UTC (rev 297) +++ trunk/javascriptlint/jsl.py 2010-04-23 20:38:04 UTC (rev 298) @@ -24,12 +24,12 @@ script = util.readfile(path) jsparse.dump_tree(script) -def _lint(paths, conf_): +def _lint(paths, conf_, printpaths): def lint_error(path, line, col, errname, errdesc): _lint_results['warnings'] = _lint_results['warnings'] + 1 print util.format_error(conf_['output-format'], path, line, col, errname, errdesc) - lint.lint_files(paths, lint_error, conf=conf_) + lint.lint_files(paths, lint_error, conf=conf_, printpaths=printpaths) def _resolve_paths(path, recurse): # Build a list of directories @@ -46,6 +46,11 @@ # force an error to be thrown if no matching files were found. return paths or [path] +def printlogo(): + # TODO: Print version number. + print "JavaScript Lint" + print "Developed by Matthias Miller (http://www.JavaScriptLint.com)" + def _profile_enabled(func, *args, **kwargs): import tempfile import hotshot @@ -83,6 +88,12 @@ help="minimal output") add("--verbose", dest="verbosity", action="store_const", const=2, help="verbose output") + add("--nologo", dest="printlogo", action="store_false", default=True, + help="suppress version information") + add("--nofilelisting", dest="printlisting", action="store_false", + default=True, help="suppress file names") + add("--nosummary", dest="printsummary", action="store_false", default=True, + help="suppress lint summary") add("--help:conf", dest="showdefaultconf", action="store_true", default=False, help="display the default configuration file") parser.set_defaults(verbosity=1) @@ -96,6 +107,9 @@ print conf.DEFAULT_CONF sys.exit() + if options.printlogo: + printlogo() + conf_ = conf.Conf() if options.conf: conf_.loadfile(options.conf) @@ -125,8 +139,12 @@ if options.dump: profile_func(_dump, paths) else: - profile_func(_lint, paths, conf_) + profile_func(_lint, paths, conf_, options.printlisting) + if options.printsummary: + print '\n%i error(s), %i warnings(s)' % (_lint_results['errors'], + _lint_results['warnings']) + if _lint_results['errors']: sys.exit(3) if _lint_results['warnings']: Modified: trunk/javascriptlint/lint.py =================================================================== --- trunk/javascriptlint/lint.py 2010-04-23 20:09:47 UTC (rev 297) +++ trunk/javascriptlint/lint.py 2010-04-23 20:38:04 UTC (rev 298) @@ -267,7 +267,7 @@ else: assert False, 'Invalid internal tag type %s' % tag['type'] -def lint_files(paths, lint_error, conf=conf.Conf()): +def lint_files(paths, lint_error, conf=conf.Conf(), printpaths=True): def lint_file(path, kind): def import_script(import_path): # The user can specify paths using backslashes (such as when @@ -281,7 +281,8 @@ normpath = util.normpath(path) if normpath in lint_cache: return lint_cache[normpath] - print normpath + if printpaths: + print normpath contents = util.readfile(path) lint_cache[normpath] = _Script() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |