From 68e5195bb7e77897c596a4d27af2c82c5e6a4cb1 Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Wed, 4 Apr 2018 14:55:27 -0700 Subject: Print message to format if any errors are found. Test: locally in support library Change-Id: I95e82459c9a6a289d2289832eb5dca40e632dbc1 --- ktlint.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ktlint.py b/ktlint.py index 697a0d6..d0c9faa 100755 --- a/ktlint.py +++ b/ktlint.py @@ -26,6 +26,12 @@ import sys MAIN_DIRECTORY = os.path.normpath(os.path.dirname(__file__)) KTLINT_JAR = os.path.join(MAIN_DIRECTORY, 'ktlint-android-all.jar') +FORMAT_MESSAGE = ''' +********************************************************************** +To format run: +{}/ktlint.py --format --file {} +********************************************************************** +''' def main(args=None): @@ -35,7 +41,8 @@ def main(args=None): parser.add_argument('--noformat', dest='format', action='store_false') parser.set_defaults(format=False) args = parser.parse_args() - ktlint_args = [f for f in args.file if f.endswith('.kt')] + kt_files = [f for f in args.file if f.endswith('.kt') or f.endswith('.kts')] + ktlint_args = kt_files[:] if args.format: ktlint_args += ['-F'] if not ktlint_args: @@ -50,6 +57,7 @@ def main(args=None): if stdout: print 'prebuilts/ktlint found errors in files you changed:' print stdout + print FORMAT_MESSAGE.format(MAIN_DIRECTORY, ' '.join(kt_files)) sys.exit(1) else: sys.exit(0) -- cgit v1.2.3