diff --git a/README.md b/README.md index fca6d68..2ddcfe3 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ bump-pydantic --help To check the diff before applying the changes, you can run: ```bash -bump-pydantic --diff +bump-pydantic --diff ``` ### Apply changes @@ -63,7 +63,7 @@ bump-pydantic --diff To apply the changes, you can run: ```bash -bump-pydantic +bump-pydantic ``` ## Rules diff --git a/bump_pydantic/main.py b/bump_pydantic/main.py index fdc3abd..32f9389 100644 --- a/bump_pydantic/main.py +++ b/bump_pydantic/main.py @@ -42,7 +42,7 @@ def version_callback(value: bool): @app.callback() def main( - package: Path = Argument(..., exists=True, dir_okay=True, allow_dash=False), + path: Path = Argument(..., exists=True, dir_okay=True, allow_dash=False), disable: List[Rule] = Option(default=[], help="Disable a rule."), log_file: Path = Option("log.txt", help="Log errors to this file."), version: bool = Option( @@ -57,8 +57,14 @@ def main( # NOTE: LIBCST_PARSER_TYPE=native is required according to https://github.com/Instagram/LibCST/issues/487. os.environ["LIBCST_PARSER_TYPE"] = "native" - files_str = list(package.glob("**/*.py")) - files = [str(file.relative_to(".")) for file in files_str] + if os.path.isfile(path): + package = path.parent + files = [str(path.relative_to("."))] + else: + package = path + files_str = list(package.glob("**/*.py")) + files = [str(file.relative_to(".")) for file in files_str] + logger.info(f"Found {len(files)} files to process.") providers = {FullyQualifiedNameProvider, ScopeProvider}