From: Rishikesh Jha Date: Wed, 4 Sep 2019 11:51:33 +0000 (+0530) Subject: Print a separate message when there are no inputs given (#999) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/ae5588cf073be10b51dc48ad2fc513e11c4f3e03?ds=inline;hp=c4d2db43231cb927c89a403e2837b7fee92a6ad5 Print a separate message when there are no inputs given (#999) Fixes #886. --- diff --git a/.gitignore b/.gitignore index 73cc19a..da4a908 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ __pycache__ black.egg-info build/ dist/ -pip-wheel-metadata/ \ No newline at end of file +pip-wheel-metadata/ +.idea diff --git a/black.py b/black.py index f178ace..71f42ef 100644 --- a/black.py +++ b/black.py @@ -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(): @@ -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: @@ -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: