Skip to content

Commit

Permalink
PLT-6750: Addressing review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
yveshauser committed Aug 18, 2023
1 parent b5d71e1 commit e4b5b3d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions marlowe-cli/command/Language/Marlowe/CLI/Command/Format.hs
Expand Up @@ -77,7 +77,15 @@ runFormatCommand Format{..} =
Just Json -> maybeWriteJson outputFile contract
Just Yaml -> maybeWriteYaml outputFile contract
Just Pretty -> maybeWritePretty outputFile contract
Nothing -> maybeWriteJson outputFile contract
Nothing ->
case outputFile of
Just fileName ->
case takeExtension fileName of
".json" -> maybeWriteJson outputFile contract
".yaml" -> maybeWriteYaml outputFile contract
".marlowe" -> maybeWritePretty outputFile contract
_ -> maybeWriteJson outputFile contract
Nothing -> maybeWriteJson outputFile contract

-- | Parser for format commands.
parseFormatCommand :: O.Parser FormatCommand
Expand All @@ -100,7 +108,7 @@ parseFormatCommand =
mconcat
[ O.long "out-file"
, O.metavar "MARLOWE_FILE"
, O.help "The Marlowe file containing the output contract. If omitted, the Marlowe contract is written to stdout."
, O.help "The Marlowe file the output contract is written to. If omitted, the Marlowe contract is written to stdout."
]
inFormatParser =
O.optional . O.option formatReader $
Expand All @@ -109,15 +117,16 @@ parseFormatCommand =
, O.metavar "FORMAT"
, O.help $
"The format of the input Marlowe contract. Known formats are: Json (default), Yaml, Marlowe. "
<> "If omitted and in-file is specified, the format is inferred from the file extension. "
<> "If omitted and in-file is specified, the format is inferred from the file extension."
]
outFormatParser =
O.optional . O.option formatReader $
mconcat
[ O.long "out-format"
, O.metavar "FORMAT"
, O.help
, O.help $
"The format of the output Marlowe contract. Known formats are: Json (default), Yaml, Marlowe. "
<> "If omitted and out-file is specified, the format is inferred from the file extension."
]

data Format = Json | Yaml | Pretty
Expand Down

0 comments on commit e4b5b3d

Please sign in to comment.