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:
parent
4dbd23af3b
commit
50f744d821
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue