mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-21 14:31:55 +03:00
044cd25df6
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4938 GitOrigin-RevId: 578a9176f5f28303b74607e008712f75c37355d8
32 lines
910 B
Haskell
32 lines
910 B
Haskell
--
|
|
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
|