1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00

Define a convenience to render a diff to Output.

This commit is contained in:
Rob Rix 2017-04-03 15:12:00 -04:00
parent e219ae99c7
commit a11623d994

View File

@ -7,6 +7,7 @@ module Command
, parse
, diff
, renderDiff
, renderDiffOutput
-- Evaluation
, runCommand
) where
@ -69,6 +70,17 @@ diff term1 term2 = Diff term1 term2 `Then` return
renderDiff :: DiffRenderer fields output -> SourceBlob -> SourceBlob -> Diff (Syntax Text) (Record fields) -> Command output
renderDiff renderer blob1 blob2 diff = RenderDiff renderer blob1 blob2 diff `Then` return
-- | Render a diff using the specified renderer, wrapping the result up in Output.
renderDiffOutput :: DiffRenderer fields output -> SourceBlob -> SourceBlob -> Diff (Syntax Text) (Record fields) -> Command Output
renderDiffOutput renderer blob1 blob2 diff = fmap output (renderDiff renderer blob1 blob2 diff)
where output = case renderer of
SplitRenderer -> SplitOutput
PatchRenderer -> PatchOutput
JSONDiffRenderer -> JSONOutput
SummaryRenderer -> SummaryOutput
SExpressionDiffRenderer _ -> SExpressionOutput
ToCRenderer -> TOCOutput
-- Evaluation