Skip to content

Commit

Permalink
Print a separate message when there are no inputs given (#999)
Browse files Browse the repository at this point in the history
Fixes #886.
  • Loading branch information
Rishi-jha authored and zsol committed Sep 4, 2019
1 parent c4d2db4 commit ae5588c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -8,4 +8,5 @@ __pycache__
black.egg-info
build/
dist/
pip-wheel-metadata/
pip-wheel-metadata/
.idea
13 changes: 12 additions & 1 deletion black.py
Expand Up @@ -437,6 +437,7 @@ def main(
report = Report(check=check, quiet=quiet, verbose=verbose)
root = find_project_root(src)
sources: Set[Path] = set()
path_empty(src, quiet, verbose, ctx)
for s in src:
p = Path(s)
if p.is_dir():
Expand All @@ -450,7 +451,7 @@ def main(
err(f"invalid path: {s}")
if len(sources) == 0:
if verbose or not quiet:
out("No paths given. Nothing to do 😴")
out("No Python files are present to be formatted. Nothing to do 😴")
ctx.exit(0)

if len(sources) == 1:
Expand All @@ -472,6 +473,16 @@ def main(
ctx.exit(report.return_code)


def path_empty(src: Tuple[str], quiet: bool, verbose: bool, ctx: click.Context) -> None:
"""
Exit if there is no `src` provided for formatting
"""
if not src:
if verbose or not quiet:
out("No Path provided. Nothing to do 😴")
ctx.exit(0)


def reformat_one(
src: Path, fast: bool, write_back: WriteBack, mode: FileMode, report: "Report"
) -> None:
Expand Down

0 comments on commit ae5588c

Please sign in to comment.