handle when getTermCols returns 0

This commit is contained in:
rhiannon morris 2023-11-05 15:40:19 +01:00
parent f58fa5218f
commit da3cd404f3

View file

@ -40,6 +40,12 @@ record Options where
%name Options opts
%runElab derive "Options" [Show]
export
defaultWidth : IO Nat
defaultWidth = do
w <- cast {to = Nat} <$> getTermCols
pure $ if w == 0 then 80 else w
export
defaultOpts : IO Options
defaultOpts = pure $ MkOpts {
@ -47,7 +53,7 @@ defaultOpts = pure $ MkOpts {
outFile = Console,
until = Nothing,
flavor = Unicode,
width = cast !getTermCols,
width = !defaultWidth,
include = ["."]
}