Tom Joad
21-01-2021, 14:40
Ciao a tutti,
sto scrivendo una piccola utility per modificare i font da riga di comando. In precedenza avevo tanti singoli script, ognuno dei quali faceva una sola cosa.
Esempio:
print-font-info.py --help
usage: print-font-info.py [-h] path
positional arguments:
path path to font or folder containing fonts, e.g. "C:\fonts" or "C:\fonts\font.otf"
optional arguments:
-h, --help show this help message and exit
Gli script col tempo sono diventati troppi da gestire, e ho deciso di razionalizzare un po' le cose creando un pacchetto installabile tramite pip, utilizzando sottocomandi anziché uno singolo script per ogni cosa.
Ora mi trovo davanti a un dubbio, dovuto dalla mia inesperienza, su come gestire i sottocomandi.
La prima opzione che ho valutato è quella di raggruppare tutti i sottocomandi in un unico script:
ftcli --help
Usage: ftcli [OPTIONS] COMMAND [ARGS]...
A command line tool to manipulate fonts with FontTools.
Options:
--help Show this message and exit.
Commands:
delname Deletes the specified nemerecord(s) from the name table.
editcfg Edits the configuration stored in the config.json file
editdb Edits the data stored in the data.csv file
findreplace Replaces a string with a new one in the specified font(s).
ftedit A command line tool to manipulate fonts with fontTools.
printftlist Print fonts list
printinfo Prints font(s) information: metrics,
printnames Prints the names stored in the 'name' table and in the 'CFF'...
recalcdb Recalculates values stored in the data.csv file.
recalcnames Recalculates namerecords according to the values stored in...
resetcfg Creates a new config.json file with following default values.
resetdb Reads the fonts values and writes them to the db.
setname Sets the specified namerecord(s) in the name table.
A questi sottocomandi se ne aggiungeranno altri, probabilmente quando avrò finito saranno più di 20. Non so se è la cosa giusta da fare, e sto valutando se suddividerli in 5 o 6 script. Ad esempio:
pyftnames --help
Usage: pyftnames [OPTIONS] COMMAND [ARGS]...
A command line tool to edit names stored in the 'name' and 'CFF' tables.
Options:
--help Show this message and exit.
Commands:
delname Deletes the specified nemerecord(s) from the 'name' table.
recalc Recalculates namerecords according to the values stored in the...
replace Replaces a string in the 'name' table with a new string.
setname Sets the specified namerecord(s) in the name table.
Quali potrebbero essere i pro e i contro di ciascuna delle due soluzioni?
sto scrivendo una piccola utility per modificare i font da riga di comando. In precedenza avevo tanti singoli script, ognuno dei quali faceva una sola cosa.
Esempio:
print-font-info.py --help
usage: print-font-info.py [-h] path
positional arguments:
path path to font or folder containing fonts, e.g. "C:\fonts" or "C:\fonts\font.otf"
optional arguments:
-h, --help show this help message and exit
Gli script col tempo sono diventati troppi da gestire, e ho deciso di razionalizzare un po' le cose creando un pacchetto installabile tramite pip, utilizzando sottocomandi anziché uno singolo script per ogni cosa.
Ora mi trovo davanti a un dubbio, dovuto dalla mia inesperienza, su come gestire i sottocomandi.
La prima opzione che ho valutato è quella di raggruppare tutti i sottocomandi in un unico script:
ftcli --help
Usage: ftcli [OPTIONS] COMMAND [ARGS]...
A command line tool to manipulate fonts with FontTools.
Options:
--help Show this message and exit.
Commands:
delname Deletes the specified nemerecord(s) from the name table.
editcfg Edits the configuration stored in the config.json file
editdb Edits the data stored in the data.csv file
findreplace Replaces a string with a new one in the specified font(s).
ftedit A command line tool to manipulate fonts with fontTools.
printftlist Print fonts list
printinfo Prints font(s) information: metrics,
printnames Prints the names stored in the 'name' table and in the 'CFF'...
recalcdb Recalculates values stored in the data.csv file.
recalcnames Recalculates namerecords according to the values stored in...
resetcfg Creates a new config.json file with following default values.
resetdb Reads the fonts values and writes them to the db.
setname Sets the specified namerecord(s) in the name table.
A questi sottocomandi se ne aggiungeranno altri, probabilmente quando avrò finito saranno più di 20. Non so se è la cosa giusta da fare, e sto valutando se suddividerli in 5 o 6 script. Ad esempio:
pyftnames --help
Usage: pyftnames [OPTIONS] COMMAND [ARGS]...
A command line tool to edit names stored in the 'name' and 'CFF' tables.
Options:
--help Show this message and exit.
Commands:
delname Deletes the specified nemerecord(s) from the 'name' table.
recalc Recalculates namerecords according to the values stored in the...
replace Replaces a string in the 'name' table with a new string.
setname Sets the specified namerecord(s) in the name table.
Quali potrebbero essere i pro e i contro di ciascuna delle due soluzioni?