Skip to content

Commit 104b6f4

Browse files
authored
Merge pull request #1152 from IntersectMBO/newhoggy/resize-based-on-terminal-width
Wrap CLI help based on terminal width
2 parents 4611950 + ac617db commit 104b6f4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cardano-cli/app/cardano-cli.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import qualified Options.Applicative as Opt
2020
import Cardano.CLI.OS.Posix
2121
#endif
2222

23+
import System.Console.Terminal.Size (Window(..), size)
24+
2325
main :: IO ()
2426
main = toplevelExceptionHandler $ do
2527
Crypto.cryptoInit
@@ -30,6 +32,12 @@ main = toplevelExceptionHandler $ do
3032
#ifdef UNIX
3133
_ <- setFileCreationMask (otherModes `unionFileModes` groupModes)
3234
#endif
33-
co <- Opt.customExecParser pref (opts envCli)
35+
36+
mWin <- size
37+
38+
let termWidth = maybe 80 width mWin
39+
dynamicPrefs = pref { Opt.prefColumns = termWidth }
40+
41+
co <- Opt.customExecParser dynamicPrefs (opts envCli)
3442

3543
orDie (docToText . renderClientCommandError) $ runClientCommand co

cardano-cli/cardano-cli.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ executable cardano-cli
305305
cardano-cli,
306306
cardano-crypto-class ^>=2.2,
307307
optparse-applicative-fork,
308+
terminal-size,
308309
transformers-except,
309310

310311
library cardano-cli-test-lib

0 commit comments

Comments
 (0)