From 8b3ef954af3570af3cf5994b25e8e23c110dcdfc Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Sun, 17 Mar 2024 20:14:25 +0000 Subject: [PATCH] Allow chws_tool to take a file path output (#191) * Allow chws_tool to take a file path output * fixup! Allow chws_tool to take a file path output --- src/chws_tool/add_chws.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/chws_tool/add_chws.py b/src/chws_tool/add_chws.py index 68ceaf5..6591591 100755 --- a/src/chws_tool/add_chws.py +++ b/src/chws_tool/add_chws.py @@ -105,7 +105,11 @@ async def main_async() -> None: help="comment level for the glyph list", ) parser.add_argument( - "-o", "--output", default="build", type=pathlib.Path, help="output directory" + "-o", + "--output", + default="build", + type=pathlib.Path, + help="output path or directory", ) parser.add_argument( "-p", @@ -120,7 +124,7 @@ async def main_async() -> None: chws.init_logging(args.verbose, main=logger) # Expand directories. - inputs = chws.Builder.expand_paths(args.inputs) + inputs = list(chws.Builder.expand_paths(args.inputs)) if args.print_name: _print_font_names(inputs) @@ -132,7 +136,9 @@ async def main_async() -> None: else: args.glyph_out = pathlib.Path(args.glyph_out) args.glyph_out.mkdir(exist_ok=True, parents=True) - args.output.mkdir(exist_ok=True, parents=True) + + if len(inputs) > 1 or not chws.Font.is_font_extension(args.output.suffix): + args.output.mkdir(exist_ok=True, parents=True) for input in inputs: await add_chws_async(