module Buffet.Toolbox.DockerTools
  ( printArguments
  , printInstruction
  ) where

import qualified Data.Text as T
import qualified Data.Text.Lazy as Lazy
import qualified Data.Text.Prettyprint.Doc as Doc
import qualified Data.Text.Prettyprint.Doc.Render.Text as Text
import qualified Language.Docker as Docker
import qualified Language.Docker.PrettyPrint as PrettyPrint
import qualified Language.Docker.Syntax as Syntax
import Prelude (($), (.), mempty)

printArguments :: Docker.Arguments T.Text -> T.Text
printArguments :: Arguments Text -> Text
printArguments =
  SimpleDocStream Any -> Text
forall ann. SimpleDocStream ann -> Text
Text.renderStrict (SimpleDocStream Any -> Text)
-> (Arguments Text -> SimpleDocStream Any)
-> Arguments Text
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc Any -> SimpleDocStream Any
forall ann1 ann2. Doc ann1 -> SimpleDocStream ann2
Doc.layoutCompact (Doc Any -> SimpleDocStream Any)
-> (Arguments Text -> Doc Any)
-> Arguments Text
-> SimpleDocStream Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Arguments Text -> Doc Any
forall ann. Arguments Text -> Doc ann
PrettyPrint.prettyPrintArguments

printInstruction :: Docker.Instruction T.Text -> T.Text
printInstruction :: Instruction Text -> Text
printInstruction Instruction Text
instruction =
  Text -> Text
Lazy.toStrict (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
$
  Dockerfile -> Text
Docker.prettyPrint [Instruction Text -> Text -> Linenumber -> InstructionPos Text
forall args.
Instruction args -> Text -> Linenumber -> InstructionPos args
Syntax.InstructionPos Instruction Text
instruction Text
forall a. Monoid a => a
mempty Linenumber
0]