Skip to content

Commit e3760e9

Browse files
committed
Fix #26 --version command and fork information in help output
1 parent a48cd5f commit e3760e9

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

cpplint.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
# if empty, use defaults
6060
_valid_extensions = set([])
6161

62+
__VERSION__ = '1.4.4'
63+
6264
try:
6365
xrange # Python 2
6466
except NameError:
@@ -76,8 +78,12 @@
7678
[--exclude=path]
7779
[--extensions=hpp,cpp,...]
7880
[--quiet]
81+
[--version]
7982
<file> [file] ...
8083
84+
Style checker for C/C++ source files.
85+
This is a fork of the Google style checker with minor extensions.
86+
8187
The style guidelines this tries to follow are those in
8288
https://google.github.io/styleguide/cppguide.html
8389
@@ -6393,6 +6399,11 @@ def PrintUsage(message):
63936399
else:
63946400
sys.exit(0)
63956401

6402+
def PrintVersion():
6403+
print('Cpplint fork (https://github.com/cpplint/cpplint)')
6404+
print('cpplint ' + __VERSION__)
6405+
print('Python ' + sys.version)
6406+
sys.exit(0)
63966407

63976408
def PrintCategories():
63986409
"""Prints a list of all the error-categories used by error messages.
@@ -6416,6 +6427,8 @@ def ParseArguments(args):
64166427
"""
64176428
try:
64186429
(opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=',
6430+
'v=',
6431+
'version',
64196432
'counting=',
64206433
'filter=',
64216434
'root=',
@@ -6439,14 +6452,16 @@ def ParseArguments(args):
64396452
for (opt, val) in opts:
64406453
if opt == '--help':
64416454
PrintUsage(None)
6455+
if opt == '--version':
6456+
PrintVersion()
64426457
elif opt == '--output':
64436458
if val not in ('emacs', 'vs7', 'eclipse', 'junit'):
64446459
PrintUsage('The only allowed output formats are emacs, vs7, eclipse '
64456460
'and junit.')
64466461
output_format = val
64476462
elif opt == '--quiet':
64486463
quiet = True
6449-
elif opt == '--verbose':
6464+
elif opt == '--verbose' or opt == '--v':
64506465
verbosity = int(val)
64516466
elif opt == '--filter':
64526467
filters = val

cpplint_unittest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3974,6 +3974,7 @@ def testParseArguments(self):
39743974
self.assertRaises(SystemExit, cpplint.ParseArguments, [])
39753975
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--badopt'])
39763976
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--help'])
3977+
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--version'])
39773978
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--v=0'])
39783979
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--filter='])
39793980
# This is illegal because all filters must start with + or -

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from subprocess import check_call
66
from multiprocessing import cpu_count
77
from distutils.spawn import find_executable
8-
8+
import cpplint as cpplint
99

1010
class Test(TestCommand):
1111
def run_tests(self):
@@ -56,7 +56,7 @@ def run(self):
5656

5757

5858
setup(name='cpplint',
59-
version='1.4.3',
59+
version=cpplint.__VERSION__,
6060
py_modules=['cpplint'],
6161
# generate platform specific start script
6262
entry_points={

0 commit comments

Comments
 (0)