1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-11-25 16:47:37 +02:00

font-patcher: Allow to specify more options in config file

[why]
At the moment we have two different config files:

config.cfg:
Is read by gotta-patch-em and allows to specify some needed
commandline options for a font-patcher run

config.json:
Is read by font-patcher and can contain ligature table removal
instructions

It would be nice to combine/unify them.

[how]
Add the possibility to add commandline options in the config.cfg
file. Of course we need commandline options to specify the config
file first, so the options are parsed in two steps.

The config.file takes precedence (if possible) over directly specified
options.

This is how the new section in the config file can look like:

[Config]
commandline: --powerlineextra --mono

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2024-04-19 14:29:01 +02:00
parent c46764cd11
commit b984447921

View File

@ -1961,6 +1961,23 @@ def setup_arguments():
args = parser.parse_args()
# if we have a config file: fetch commandline arguments from there and process again with all arguments
if args.configfile:
if not os.path.isfile(args.configfile):
logger.critical("Configfile does not exist: %s", args.configfile)
sys.exit(1)
if not os.access(args.configfile, os.R_OK):
logger.critical("Can not open configfile for reading: %s", args.configfile)
sys.exit(1)
config = configparser.ConfigParser(empty_lines_in_values=False, allow_no_value=True)
config.read(args.configfile)
extraflags = config.get("Config", "commandline", fallback='')
if len(extraflags):
# We have no level less severe than warning here, logger will be set up later
logger.warning("Adding config commandline options: %s", extraflags)
extraflags += ' ' + args.font
args = parser.parse_args(extraflags.split(), args)
if args.makegroups > 0 and not FontnameParserOK:
logger.critical("FontnameParser module missing (bin/scripts/name_parser/Fontname*), specify --makegroups 0")
sys.exit(1)