Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept directories as input #252

Closed
baggiponte opened this issue Jun 16, 2023 · 1 comment
Closed

Accept directories as input #252

baggiponte opened this issue Jun 16, 2023 · 1 comment

Comments

@baggiponte
Copy link

Description

When I run blacken docs src I get an error because it is a directory. I would say it'd be a nice addition if this could work by default. I checked the source code and this could easily be achieved doing something like this:

from pathlib import Path


def main(argv: Sequence[str] | None = None) -> None:
    """Main entry point for the program."""
    parser = argparse.ArgumentParser()
    parser.add_argument("filenames", nargs="*")
    args = parser.parse_args(argv)

    for filename in args.filenames:
        retv = 0
        for file in Path(filename).rglob("*"):
            ...

If you agree, I would like to propose a PR.

@adamchainz
Copy link
Owner

I'd rather avoid adding and maintaining undifferentiated features like recursion (the next request would be glob patterns, ...). It's not hard to compose shell globbing or git ls-files + xargs to apply to all the files you want. I've added some docs in #269 that cover this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants