[ttx] use GNU-style getopt to intermix options and positional arguments

Fixes https://github.com/fonttools/fonttools/issues/3507
This commit is contained in:
Cosimo Lupo 2024-05-17 12:07:59 +01:00
parent 969d09dcaf
commit 511024bdc9
2 changed files with 10 additions and 1 deletions

View File

@ -375,7 +375,7 @@ def guessFileType(fileName):
def parseOptions(args):
rawOptions, files = getopt.getopt(
rawOptions, files = getopt.gnu_getopt(
args,
"ld:o:fvqht:x:sgim:z:baey:",
[

View File

@ -1018,6 +1018,15 @@ def test_main_ttx_compile_stdin_to_stdout(tmp_path):
assert outpath.is_file()
def test_main_gnu_style_opts_and_args_intermixed(tmpdir):
# https://github.com/fonttools/fonttools/issues/3507
inpath = os.path.join("Tests", "ttx", "data", "TestTTF.ttf")
outpath = tmpdir.join("TestTTF.ttx")
args = ["-t", "cmap", inpath, "-o", str(outpath)]
ttx.main(args)
assert outpath.check(file=True)
def test_roundtrip_DSIG_split_at_XML_parse_buffer_size(tmp_path):
inpath = Path("Tests").joinpath(
"ttx", "data", "roundtrip_DSIG_split_at_XML_parse_buffer_size.ttx"