Skip to content

Commit d5dfb12

Browse files
committed
added percent value testing to prevent values <= 0 and warn for values > 100
1 parent efd3b4a commit d5dfb12

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/fontline/app.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,15 @@ def main():
6363
sys.exit(1)
6464
else:
6565
percent = c.argv[1]
66+
# test the percent integer argument
6667
try:
67-
int(percent) # test that the argument can be cast to an integer value
68+
percent_int = int(percent) # test that the argument can be cast to an integer value
69+
if percent_int <= 0:
70+
stderr("[font-line] ERROR: Please enter a percent value that is greater than zero.")
71+
sys.exit(1)
72+
if percent_int > 100:
73+
stdout("[font-line] Warning: You entered a percent value over 100%. Please confirm that this is "
74+
"your intended metrics modification.")
6875
except ValueError:
6976
stderr("[font-line] ERROR: You entered '" + percent + "'. This argument needs to be an integer value.")
7077
sys.exit(1)
@@ -73,8 +80,7 @@ def main():
7380
if is_supported_filetype(fontpath):
7481
if modify_linegap_percent(fontpath, percent) is True:
7582
outpath = get_linegap_percent_filepath(fontpath, percent)
76-
stdout("[font-line] '" + fontpath + "' successfully modified and is available at '" +
77-
outpath + "'.")
83+
stdout("[font-line] '" + fontpath + "' successfully modified to '" + outpath + "'.")
7884
else:
7985
stderr("[font-line] ERROR: Unsuccessful modification of '" + fontpath + "'.")
8086
else:

0 commit comments

Comments
 (0)