Commit 29be8093 authored by wiebel's avatar wiebel
Browse files

[FIX] corrected usage info

parent 330aa254
......@@ -62,7 +62,7 @@ import unicodedata
_USAGE = """
Syntax: [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
Syntax: [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
<file> [file] ...
The style guidelines this tries to follow are those in
......@@ -87,6 +87,10 @@ Syntax: [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
Specify a number 0-5 to restrict errors to certain verbosity levels.
If this flag is present the output will be colored using ANSI
escape sequences for coloring output on text terminals
Specify a comma-separated list of category-filters to apply: only
error messages whose category names pass the filters will be printed.
......@@ -99,7 +103,7 @@ Syntax: [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
To see a list of all the categories used in cpplint, pass no arg:
To see a list of all the categories used in brainlint, pass no arg:
......@@ -353,6 +357,7 @@ class _CppLintState(object):
def __init__(self):
self.verbose_level = 1 # global setting.
self.error_count = 0 # global count of reported errors
self.useColorFlag = False # flag defining whether to color output by escape sequences
self.filters = [] # filters to apply when emitting error messages
# output format:
......@@ -370,6 +375,10 @@ class _CppLintState(object):
self.verbose_level = level
return last_verbose_level
def SetUseColor(self, useColor):
"""Sets whether to use escape sequences for colored output."""
self.useColorFlag = useColor
def SetFilters(self, filters):
"""Sets the error-message filters.
......@@ -424,6 +433,14 @@ def _SetVerboseLevel(level):
"""Sets the module's verbosity, and returns the previous setting."""
return _cpplint_state.SetVerboseLevel(level)
def _UseColor():
"""Returns the whether escape sequences for coloring messages should be used."""
return _cpplint_state.useColorFlag
def _SetUseColor(useColor):
"""Sets the module's verbosity, and returns the previous setting."""
return _cpplint_state.SetUseColor(useColor)
def _Filters():
"""Returns the module's list of output filters, as a list."""
......@@ -630,6 +647,26 @@ def Error(filename, linenum, category, confidence, message):
and 1 meaning that it could be a legitimate construct.
message: The error message.
# Here we give some names to the ANSI escape sequences for colors
# These escape sequences are interpreted as colors in most
# unix-like console emulators. If coloring is not supported
# the sequnces just appear as characters.
red = "\033[31m"
green = "\033[32m"
yellow= "\033[33m"
blue = "\033[34m"
magenta= "\033[35m"
cyan = "\033[36m"
white = "\033[37m"
default= "\033[0m"
# if requested to do so write the color code
if _UseColor():
# There are two ways we might decide not to print an error message:
# the verbosity level isn't high enough, or the filters filter it out.
if _ShouldPrintError(category, confidence):
......@@ -641,6 +678,11 @@ def Error(filename, linenum, category, confidence, message):
sys.stderr.write('%s:%s: %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
# restore default color if coloring has been switched on
if _UseColor():
# Matches standard C++ escape esequences per of the C++ standard.
......@@ -2672,13 +2714,14 @@ def ParseArguments(args):
(opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=',
'filter=', 'color'])
except getopt.GetoptError:
PrintUsage('Invalid arguments.')
verbosity = _VerboseLevel()
output_format = _OutputFormat()
filters = ''
useColor = _UseColor()
for (opt, val) in opts:
if opt == '--help':
......@@ -2689,6 +2732,8 @@ def ParseArguments(args):
output_format = val
elif opt == '--verbose':
verbosity = int(val)
elif opt == '--color':
useColor = True
elif opt == '--filter':
filters = val
if not filters:
......@@ -2699,6 +2744,7 @@ def ParseArguments(args):
return filenames
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment