[subset] allow to pass --options=... before the fontfile positional argument
The code in main() assumes that the first of the args which are not consumed by Options.parse_opts(args) is the positional argument (ie. does not start with '--') for the input font file, and that is what the usage() says too. However I find it myself writing --options=... first, and then at the end the positional arguments, as is the convention for many other Unix tools. This patch makes this possible, while also keeping the current behavior.
This commit is contained in:
parent
2c142d7390
commit
f168c0ccb5
@ -2494,11 +2494,12 @@ class Options(object):
|
||||
setattr(self, k, v)
|
||||
|
||||
def parse_opts(self, argv, ignore_unknown=False):
|
||||
ret = []
|
||||
posargs = []
|
||||
passthru_options = []
|
||||
for a in argv:
|
||||
orig_a = a
|
||||
if not a.startswith('--'):
|
||||
ret.append(a)
|
||||
posargs.append(a)
|
||||
continue
|
||||
a = a[2:]
|
||||
i = a.find('=')
|
||||
@ -2528,7 +2529,7 @@ class Options(object):
|
||||
k = k.replace('-', '_')
|
||||
if not hasattr(self, k):
|
||||
if ignore_unknown is True or ok in ignore_unknown:
|
||||
ret.append(orig_a)
|
||||
passthru_options.append(orig_a)
|
||||
continue
|
||||
else:
|
||||
raise self.UnknownOptionError("Unknown option '%s'" % a)
|
||||
@ -2565,7 +2566,7 @@ class Options(object):
|
||||
|
||||
setattr(self, k, v)
|
||||
|
||||
return ret
|
||||
return posargs + passthru_options
|
||||
|
||||
|
||||
class Subsetter(object):
|
||||
|
Loading…
x
Reference in New Issue
Block a user