Skip to content

Commit 9918310

Browse files
redsun82Copilot
andcommitted
Just: refuse a path that is not there rather than formatting nothing
Naming a file is an assertion that it exists, and a typo in one was answered with the silence that means everything already matched, exit 0 included, under a banner claiming the formatter had run on it. Only the named path is checked: a directory holding nothing to format is a fair answer, and so is a glob whose expansion this formatter does not claim. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 9b67e8f commit 9918310

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

misc/just/run_on_files.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
88
The command is run once per batch of file names rather than once per file, and the
99
batches are sized so that no single command line runs into a length limit. Nothing is
10-
run at all when no file matches.
10+
run at all when no file matches, so silence means that nothing here matched rather than
11+
that nothing was there: a path that does not exist is refused instead, naming one being
12+
an assertion that it does.
1113
"""
1214

1315
import argparse
@@ -160,6 +162,9 @@ def parse_args():
160162
args.command, args.paths = args.rest[:separator], args.rest[separator + 1 :]
161163
if not args.command:
162164
parser.error("no command given")
165+
missing = [path for path in args.paths if not os.path.exists(path)]
166+
if missing:
167+
parser.error("no such path: " + ", ".join(missing))
163168
return args
164169

165170

0 commit comments

Comments
 (0)