Print a separate message when there are no inputs given (#999)
Fixes #886.
This commit is contained in:
parent
c4d2db4323
commit
ae5588cf07
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ black.egg-info
|
|||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
pip-wheel-metadata/
|
pip-wheel-metadata/
|
||||||
|
.idea
|
||||||
|
13
black.py
13
black.py
@ -437,6 +437,7 @@ def main(
|
|||||||
report = Report(check=check, quiet=quiet, verbose=verbose)
|
report = Report(check=check, quiet=quiet, verbose=verbose)
|
||||||
root = find_project_root(src)
|
root = find_project_root(src)
|
||||||
sources: Set[Path] = set()
|
sources: Set[Path] = set()
|
||||||
|
path_empty(src, quiet, verbose, ctx)
|
||||||
for s in src:
|
for s in src:
|
||||||
p = Path(s)
|
p = Path(s)
|
||||||
if p.is_dir():
|
if p.is_dir():
|
||||||
@ -450,7 +451,7 @@ def main(
|
|||||||
err(f"invalid path: {s}")
|
err(f"invalid path: {s}")
|
||||||
if len(sources) == 0:
|
if len(sources) == 0:
|
||||||
if verbose or not quiet:
|
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)
|
ctx.exit(0)
|
||||||
|
|
||||||
if len(sources) == 1:
|
if len(sources) == 1:
|
||||||
@ -472,6 +473,16 @@ def main(
|
|||||||
ctx.exit(report.return_code)
|
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(
|
def reformat_one(
|
||||||
src: Path, fast: bool, write_back: WriteBack, mode: FileMode, report: "Report"
|
src: Path, fast: bool, write_back: WriteBack, mode: FileMode, report: "Report"
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user