mirror of
https://github.com/github/semantic.git
synced 2024-11-24 00:42:33 +03:00
Merge pull request #2148 from github/show-colourful-output-in-terminals
Show colourful output in terminals
This commit is contained in:
commit
61231d2379
@ -33,5 +33,5 @@ data ASTFormat = SExpression | JSON | Show
|
||||
|
||||
runASTParse :: (Member Distribute effects, Member (Exc SomeException) effects, Member Task effects) => ASTFormat -> [Blob] -> Eff effects F.Builder
|
||||
runASTParse SExpression = distributeFoldMap (astParseBlob >=> withSomeAST (serialize (F.SExpression F.ByShow)))
|
||||
runASTParse Show = distributeFoldMap (astParseBlob >=> withSomeAST (serialize F.Show))
|
||||
runASTParse Show = distributeFoldMap (astParseBlob >=> withSomeAST (serialize F.Show . fmap nodeSymbol))
|
||||
runASTParse JSON = distributeFoldMap (\ blob -> astParseBlob blob >>= withSomeAST (render (renderJSONAST blob))) >=> serialize F.JSON
|
||||
|
@ -13,6 +13,7 @@ import Analysis.PackageDef (HasPackageDef)
|
||||
import Data.AST
|
||||
import Data.Blob
|
||||
import Data.JSON.Fields
|
||||
import Data.Quieterm
|
||||
import Data.Record
|
||||
import Data.Term
|
||||
import Parsing.Parser
|
||||
@ -30,7 +31,7 @@ import qualified Language.Python.Assignment as Python
|
||||
runParse :: (Member Distribute effs, Member (Exc SomeException) effs, Member Task effs) => TermRenderer output -> [Blob] -> Eff effs Builder
|
||||
runParse JSONTermRenderer = withParsedBlobs (render . renderJSONTerm) >=> serialize JSON
|
||||
runParse SExpressionTermRenderer = withParsedBlobs (const (serialize (SExpression ByConstructorName)))
|
||||
runParse ShowTermRenderer = withParsedBlobs (const (serialize Show))
|
||||
runParse ShowTermRenderer = withParsedBlobs (const (serialize Show . quieterm))
|
||||
runParse (SymbolsTermRenderer fields) = withParsedBlobs (\ blob -> decorate (declarationAlgebra blob) >=> render (renderSymbolTerms . renderToSymbols fields blob)) >=> serialize JSON
|
||||
runParse DOTTermRenderer = withParsedBlobs (const (render renderTreeGraph)) >=> serialize (DOT (termStyle "terms"))
|
||||
|
||||
|
@ -187,7 +187,7 @@ runTaskF = interpret $ \ task -> case task of
|
||||
Semantic.Task.Diff terms -> pure (diffTermPair terms)
|
||||
Render renderer input -> pure (renderer input)
|
||||
Serialize format input -> do
|
||||
formatStyle <- asks (bool Colourful Plain . configIsTerminal)
|
||||
formatStyle <- asks (bool Plain Colourful . configIsTerminal)
|
||||
pure (runSerialize formatStyle format input)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user