-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make some of CLI options for dhall-json more consistent #1475
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,7 +199,6 @@ module Dhall.JSON ( | |
dhallToJSON | ||
, omitNull | ||
, omitEmpty | ||
, parseOmission | ||
, parsePreservationAndOmission | ||
, Conversion(..) | ||
, convertToHomogeneousMaps | ||
|
@@ -609,7 +608,7 @@ omitEmpty (Object object) = | |
omitEmpty (Array array) = | ||
if null elems then Null else Array elems | ||
where | ||
elems = (fmap omitEmpty array) | ||
elems = Vector.filter (/= Null) (fmap omitEmpty array) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a bug |
||
omitEmpty (String string) = | ||
String string | ||
omitEmpty (Number number) = | ||
|
@@ -623,30 +622,24 @@ omitEmpty Null = | |
parseOmission :: Parser (Value -> Value) | ||
parseOmission = | ||
Options.Applicative.flag' | ||
omitNull | ||
( Options.Applicative.long "omitNull" | ||
<> Options.Applicative.help "Omit record fields that are null" | ||
) | ||
<|> Options.Applicative.flag' | ||
omitEmpty | ||
( Options.Applicative.long "omitEmpty" | ||
( Options.Applicative.long "omit-empty" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking! Seems like a bit of an unfortunate oversight! Let's maybe keep the |
||
<> Options.Applicative.help "Omit record fields that are null or empty records" | ||
) | ||
<|> pure id | ||
|
||
-- | Parser for command-line options related to preserving null fields. | ||
parseNullPreservation :: Parser (Value -> Value) | ||
parseNullPreservation = | ||
Options.Applicative.flag | ||
omitNull | ||
id | ||
( Options.Applicative.long "preserveNull" | ||
( Options.Applicative.long "preserve-null" | ||
<> Options.Applicative.help "Preserve record fields that are null" | ||
) | ||
|
||
-- | Combines parsers for command-line options related to preserving & omitting null fields. | ||
parsePreservationAndOmission :: Parser (Value -> Value) | ||
parsePreservationAndOmission = parseNullPreservation <|> parseOmission <|> pure id | ||
parsePreservationAndOmission = parseOmission <|> parseNullPreservation | ||
|
||
{-| Specify whether or not to convert association lists of type | ||
@List { mapKey: Text, mapValue : v }@ to records | ||
|
@@ -1038,7 +1031,7 @@ parseConversion = | |
noConversion = | ||
Options.Applicative.flag' | ||
NoConversion | ||
( Options.Applicative.long "noMaps" | ||
( Options.Applicative.long "no-maps" | ||
<> Options.Applicative.help "Disable conversion of association lists to homogeneous maps" | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes below have already been released. Can you separate the new entries?