mirror of
https://github.com/gren-lang/compiler.git
synced 2024-09-20 05:17:09 +03:00
Fix some terminal help issues.
This commit is contained in:
parent
ec26054a26
commit
42c38389ea
@ -66,10 +66,22 @@ exitWith code docs =
|
||||
P.renderPretty 1 80 $
|
||||
adjust $
|
||||
P.vcat $
|
||||
concatMap (\d -> [d, ""]) docs
|
||||
concatMap (\d -> [d, ""]) $
|
||||
trimDocs docs
|
||||
hPutStrLn stderr ""
|
||||
Exit.exitWith code
|
||||
|
||||
trimDocs :: [P.Doc] -> [P.Doc]
|
||||
trimDocs docs =
|
||||
let reversed =
|
||||
case reverse docs of
|
||||
[] -> []
|
||||
first : rest ->
|
||||
case P.renderCompact first of
|
||||
P.SEmpty -> rest
|
||||
_ -> first : rest
|
||||
in reverse reversed
|
||||
|
||||
getExeName :: IO String
|
||||
getExeName =
|
||||
FP.takeFileName <$> Env.getProgName
|
||||
@ -173,15 +185,15 @@ exitWithOverview intro outro maybePrefix commands =
|
||||
exitSuccess
|
||||
[ intro,
|
||||
"The most common commands are:",
|
||||
P.indent 4 $ stack $ Maybe.mapMaybe (toSummary exeName) commands,
|
||||
P.indent 4 $ stack $ Maybe.mapMaybe (toSummary exeName maybePrefix) commands,
|
||||
"There are a bunch of other commands as well though. Here is a full list:",
|
||||
P.indent 4 $ P.dullcyan $ toCommandList exeName maybePrefix commands,
|
||||
"Adding the --help flag gives a bunch of additional details about each one.",
|
||||
outro
|
||||
]
|
||||
|
||||
toSummary :: String -> Command -> Maybe P.Doc
|
||||
toSummary exeName cmd =
|
||||
toSummary :: String -> Maybe String -> Command -> Maybe P.Doc
|
||||
toSummary exeName maybePrefix cmd =
|
||||
case cmd of
|
||||
Prefix _ _ _ _ ->
|
||||
Nothing
|
||||
@ -190,9 +202,15 @@ toSummary exeName cmd =
|
||||
Uncommon ->
|
||||
Nothing
|
||||
Common summaryString ->
|
||||
Just $
|
||||
let prefixSep =
|
||||
case maybePrefix of
|
||||
Just prefix ->
|
||||
" " ++ prefix ++ " "
|
||||
Nothing ->
|
||||
" "
|
||||
in Just $
|
||||
P.vcat
|
||||
[ P.cyan $ argsToDoc (exeName ++ " " ++ name) (head args),
|
||||
[ P.cyan $ argsToDoc (exeName ++ prefixSep ++ name) (head args),
|
||||
P.indent 4 $ reflow summaryString
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user