Skip to content

Commit 6d819f1

Browse files
committed
Support multiple docx paths on command line
This is needed for pre-commit compatibility; it calls the hook program with all paths, rather than one at a time.
1 parent c7a1456 commit 6d819f1

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/docxplain/cli.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ def main() -> None:
1010
"""Command-line entrypoint."""
1111
parser = create_parser()
1212
args = parser.parse_args()
13-
changed = convert_file(args.source, suffix=args.suffix, header=args.header)
14-
if changed:
13+
14+
change_count = 0
15+
for docx_file in args.source:
16+
if convert_file(docx_file, suffix=args.suffix, header=args.header):
17+
change_count += 1
18+
print(f"Updating plain text mirror of {docx_file}")
19+
if change_count > 0:
1520
sys.exit(1)
1621
else:
1722
sys.exit(0)
1823

1924

2025
def create_parser() -> argparse.ArgumentParser:
2126
parser = argparse.ArgumentParser(description="Convert docx to plain text.")
22-
parser.add_argument("source")
27+
parser.add_argument("source", nargs="*", help="Path(s) to Word docx files")
2328
parser.add_argument(
2429
"--suffix", default=".txt", help="File suffix for plain text file."
2530
)

0 commit comments

Comments
 (0)