From 7d553e5a8ed520f27bf2d2439a5850cc00302c13 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Thu, 6 Mar 2025 13:07:15 +0100 Subject: [PATCH] Log changed files --- standardize_test_format/__main__.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/standardize_test_format/__main__.py b/standardize_test_format/__main__.py index 23693e3..061ae38 100644 --- a/standardize_test_format/__main__.py +++ b/standardize_test_format/__main__.py @@ -1,8 +1,11 @@ import argparse import pathlib +import logging from . import Config, NamingScheme, standardize_java_text +logger = logging.getLogger(__name__) + def test_files(repo: pathlib.Path) -> list[pathlib.Path]: return list(repo.rglob('*.java')) @@ -21,13 +24,14 @@ def standardize_in_file( config, ) if text_updated == text: - return + return False if inline: with open(path, 'w') as f: f.write(text_updated) else: print(text_updated) + return True def argument_parser(): @@ -65,6 +69,7 @@ def argument_parser(): def main(): + logging.basicConfig(level='INFO') args = argument_parser().parse_args() config = Config( @@ -75,12 +80,21 @@ def main(): naming_scheme=args.naming, ) + num_modified = 0 for path in test_files(args.repo): - standardize_in_file( + was_modified = standardize_in_file( path, inline=args.i, config=config, ) + if was_modified: + num_modified += 1 + logger.info('Standardized %s', path) + + logger.info('Standardized %d files', num_modified) + if not args.i: + logger.warning('This was a dry run') + logger.warning('Use -i to replace in files!') if __name__ == '__main__':