handle `terminalWidth` exception (#80)

`terminalWidth()` may fail with a `ValueError` on out of range widths
from environment variables. Provide a suitable fallback.
This commit is contained in:
Etan Kissling 2023-06-08 15:28:44 +02:00 committed by GitHub
parent 4dbd23af3b
commit 50f744d821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -376,7 +376,11 @@ proc showHelp(help: var string,
appInfo.maxNameLen = cmd.maxNameLen
appInfo.hasAbbrs = cmd.hasAbbrs
appInfo.terminalWidth = terminalWidth()
appInfo.terminalWidth =
try:
terminalWidth()
except ValueError:
int.high # https://github.com/nim-lang/Nim/pull/21968
appInfo.namesWidth = min(minNameWidth, appInfo.maxNameLen) + descPadding
var cmdInvocation = appInfo.appInvocation