Skip to content

Commit f2bb3ab

Browse files
committed
return output from blacktex.cli.main
1 parent 045ac92 commit f2bb3ab

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/blacktex/cli.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ def main(argv=None):
88
parser = _get_parser()
99
args = parser.parse_args(argv)
1010

11+
stdout = []
1112
for fl in args.infiles:
1213
content = fl.read()
1314
out = blacktex.clean(content, args.keep_comments, args.keep_dollar_math)
1415
if args.in_place:
1516
with open(fl.name, "w") as f:
1617
f.write(out)
1718
else:
18-
print(out)
19+
stdout.append(out)
20+
21+
if not args.in_place:
22+
return "\n".join(stdout)
1923

2024

2125
def _get_parser():

test/test_cli.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ def test_cli():
88
with tempfile.TemporaryDirectory() as tmpdir:
99
tmpdir = Path(tmpdir)
1010
infile = tmpdir / "in.tex"
11-
outfile = tmpdir / "out.tex"
1211
with open(infile, "w") as f:
1312
f.write("a+b=c")
1413

15-
blacktex.cli.main([str(infile), str(outfile)])
14+
stdout = blacktex.cli.main([str(infile)])
1615

17-
with open(outfile) as f:
18-
line = f.read()
19-
assert line == "a+b = c"
16+
assert stdout == "a+b = c"

0 commit comments

Comments
 (0)