Add new option --force, which forces evaluation results to normal form

This commit is contained in:
John Wiegley 2018-04-17 18:12:19 -07:00
parent 6650dd827a
commit dfe9869472
2 changed files with 9 additions and 1 deletions

View file

@ -74,7 +74,10 @@ main = do
. A.encodingToLazyByteString
. toEncodingSorted
<=< fromNix
| otherwise = liftIO . print
| normalize opts =
liftIO . print . prettyNixValue <=< normalForm
| otherwise =
liftIO . print
if | evaluate opts, verbose opts >= Debug ->
runLazyM opts $ evaluateExpression mpath

View file

@ -14,6 +14,7 @@ data Options = Options
, parseOnly :: Bool
, findFile :: Maybe FilePath
, strict :: Bool
, normalize :: Bool
, evaluate :: Bool
, json :: Bool
, xml :: Bool
@ -39,6 +40,7 @@ defaultOptions = Options
, parseOnly = False
, findFile = Nothing
, strict = False
, normalize = False
, evaluate = False
, json = False
, xml = False
@ -103,6 +105,9 @@ nixOptions = Options
<*> switch
( long "strict"
<> help "When used with --eval, recursively evaluate list elements and attributes")
<*> switch
( long "force"
<> help "Whether to force the results of evaluation to normal form")
<*> switch
( long "eval"
<> help "Whether to evaluate, or just pretty-print")