1
0
mirror of https://github.com/hasura/graphql-engine.git synced 2024-12-22 15:01:39 +03:00
graphql-engine/server/src-lib/Hasura/Server/Init/Arg/PrettyPrinter.hs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
910 B
Haskell
Raw Normal View History

--
module Hasura.Server.Init.Arg.PrettyPrinter
( (PP.<$>),
PP.Doc,
PP.text,
mkEnvVarDoc,
mkExamplesDoc,
)
where
--------------------------------------------------------------------------------
import Hasura.Prelude
import Text.PrettyPrint.ANSI.Leijen qualified as PP
--------------------------------------------------------------------------------
mkEnvVarDoc :: [(String, String)] -> PP.Doc
mkEnvVarDoc envVars =
PP.text "Environment variables: "
PP.<$> PP.indent 2 (PP.vsep $ map mkEnvVarLine envVars)
where
mkEnvVarLine (var, desc) =
(PP.fillBreak 40 (PP.text var) PP.<+> prettifyDesc desc) <> PP.hardline
prettifyDesc = PP.align . PP.fillSep . map PP.text . words
mkExamplesDoc :: [[String]] -> PP.Doc
mkExamplesDoc exampleLines =
PP.text "Examples: " PP.<$> PP.indent 2 (PP.vsep examples)
where
examples = map PP.text $ intercalate [""] exampleLines