fontpie
fontpie copied to clipboard
fix: cli options behavior
We use commander.js for creating CLI. There is a strange behavior which more a bug than a feature.
When user makes a mistake and uses "-name" option instead "--name" commander is parsing it as "-n ame".
So, for the command
npx fontpie ./roboto-regular.ttf -name "Roboto"
our user gets
@font-face {
font-family: 'ame';
^^^^^
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('examples/roboto-regular.ttf') format('truetype');
}
@font-face {
font-family: 'ame Fallback';
^^^^^
font-style: normal;
font-weight: 400;
src: local('Times New Roman');
ascent-override: 84.57%;
descent-override: 22.25%;
line-gap-override: 0.00%;
size-adjust: 109.71%;
}
html {
font-family: 'ame', 'ame Fallback';
^^^^^
}
Acceptable fix
Show error to user in terminal and stop execution.
Ideal fix
Use font filename as font name in CSS and show notice to user in terminal.