Improve help messages

This commit is contained in:
Julian Ospald 2020-04-17 22:11:41 +02:00
parent a773da037c
commit 7742fe08b5
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28

View File

@ -43,6 +43,7 @@ import HPath
import HPath.IO import HPath.IO
import Language.Haskell.TH import Language.Haskell.TH
import Options.Applicative hiding ( style ) import Options.Applicative hiding ( style )
import Options.Applicative.Help.Pretty ( text )
import Prelude hiding ( appendFile ) import Prelude hiding ( appendFile )
import System.Console.Pretty import System.Console.Pretty
import System.Environment import System.Environment
@ -164,14 +165,14 @@ com =
( command ( command
"install" "install"
((info ((Install <$> installOpts) <**> helper) ((info ((Install <$> installOpts) <**> helper)
(progDesc "Install or update GHC") (progDesc "Install or update GHC" <> footerDoc (Just $ text installFooter))
) )
) )
<> command <> command
"set" "set"
( SetGHC ( SetGHC
<$> (info (setGHCOpts <**> helper) <$> (info (setGHCOpts <**> helper)
(progDesc "Set currently active GHC version") (progDesc "Set currently active GHC version" <> footerDoc (Just $ text setFooter))
) )
) )
<> command <> command
@ -183,7 +184,7 @@ com =
<> command <> command
"install-cabal" "install-cabal"
((info ((InstallCabal <$> installOpts) <**> helper) ((info ((InstallCabal <$> installOpts) <**> helper)
(progDesc "Install or update cabal") (progDesc "Install or update cabal" <> footerDoc (Just $ text installCabalFooter))
) )
) )
<> command <> command
@ -224,6 +225,22 @@ com =
<> commandGroup "Other commands:" <> commandGroup "Other commands:"
<> hidden <> hidden
) )
where
installFooter = [i|Discussion:
Installs the specified GHC version (or a recommended default one) into
a self-contained "~/.ghcup/ghc/<ghcver>" directory
and symlinks the ghc binaries to "~/.ghcup/bin/<binary>-<ghcver>".|]
setFooter = [i|Discussion:
Sets the the current GHC version by creating non-versioned
symlinks for all ghc binaries of the specified version in
"~/.ghcup/bin/<binary>".|]
installCabalFooter = [i|Discussion:
Installs the specified cabal-install version (or a recommended default one)
into "~/.ghcup/bin", so it can be overwritten by later
"cabal install cabal-install", which installs into "~/.cabal/bin" by
default. Make sure to set up your PATH appropriately, so the cabal
installation takes precedence.|]
installOpts :: Parser InstallOptions installOpts :: Parser InstallOptions
@ -276,17 +293,34 @@ compileP = subparser
( command ( command
"ghc" "ghc"
( CompileGHC ( CompileGHC
<$> (info (compileOpts <**> helper) (progDesc "Compile GHC from source") <$> (info (compileOpts <**> helper) (progDesc "Compile GHC from source" <> footerDoc (Just $ text compileFooter))
) )
) )
<> command <> command
"cabal" "cabal"
( CompileCabal ( CompileCabal
<$> (info (compileOpts <**> helper) <$> (info (compileOpts <**> helper)
(progDesc "Compile Cabal from source") (progDesc "Compile Cabal from source" <> footerDoc (Just $ text compileCabalFooter))
) )
) )
) )
where
compileFooter = [i|Discussion:
Compiles and installs the specified GHC version into
a self-contained "~/.ghcup/ghc/<ghcver>" directory
and symlinks the ghc binaries to "~/.ghcup/bin/<binary>-<ghcver>".
Examples:
ghcup compile ghc -j 4 -v 8.4.2 -b 8.2.2
ghcup compile ghc -j 4 -v 8.4.2 -b /usr/bin/ghc-8.2.2|]
compileCabalFooter = [i|Discussion:
Compiles and installs the specified Cabal version
into "~/.ghcup/bin".
Examples:
ghcup compile cabal -j 4 -v 3.2.0.0 -b 8.6.5
ghcup compile cabal -j 4 -v 3.2.0.0 -b /usr/bin/ghc-8.6.5|]
compileOpts :: Parser CompileOptions compileOpts :: Parser CompileOptions
@ -531,16 +565,24 @@ main = do
( ("The GHCup Haskell installer, version " <>) ( ("The GHCup Haskell installer, version " <>)
$ (head . lines $ describe_result) $ (head . lines $ describe_result)
) )
(long "version" <> help "Show version") (long "version" <> help "Show version" <> hidden)
let numericVersionHelp = infoOption let numericVersionHelp = infoOption
numericVer numericVer
( long "numeric-version" ( long "numeric-version"
<> help "Show the numeric version (for use in scripts)" <> help "Show the numeric version (for use in scripts)"
<> hidden
) )
let main_footer = [i|Discussion:
ghcup installs the Glasgow Haskell Compiler from the official
release channels, enabling you to easily switch between different
versions.
Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
customExecParser customExecParser
(prefs showHelpOnError) (prefs showHelpOnError)
(info (opts <**> helper <**> versionHelp <**> numericVersionHelp) idm) (info (opts <**> helper <**> versionHelp <**> numericVersionHelp) (footerDoc (Just $ text main_footer)))
>>= \opt@Options {..} -> do >>= \opt@Options {..} -> do
let settings = toSettings opt let settings = toSettings opt