Skip to content

Wrap CLI help based on terminal width #1152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cardano-cli/app/cardano-cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import qualified Options.Applicative as Opt
import Cardano.CLI.OS.Posix
#endif

import System.Console.Terminal.Size (Window(..), size)

main :: IO ()
main = toplevelExceptionHandler $ do
Crypto.cryptoInit
Expand All @@ -30,6 +32,12 @@ main = toplevelExceptionHandler $ do
#ifdef UNIX
_ <- setFileCreationMask (otherModes `unionFileModes` groupModes)
#endif
co <- Opt.customExecParser pref (opts envCli)

mWin <- size

let termWidth = maybe 80 width mWin
dynamicPrefs = pref { Opt.prefColumns = termWidth }

co <- Opt.customExecParser dynamicPrefs (opts envCli)

orDie (docToText . renderClientCommandError) $ runClientCommand co
1 change: 1 addition & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ executable cardano-cli
cardano-cli,
cardano-crypto-class ^>=2.2,
optparse-applicative-fork,
terminal-size,
transformers-except,

library cardano-cli-test-lib
Expand Down
Loading