ADD: Add JSON output (-j, --json).

This commit is contained in:
Thomas M. Edwards 2021-02-10 16:22:52 -06:00
parent 33a6da381c
commit 3a8dfb2344
8 changed files with 175 additions and 92 deletions

View file

@ -64,6 +64,11 @@ func buildOutput(c *config) *story {
// Write the output.
switch c.outMode {
case outModeJSON:
// Write out the project as JSON.
if _, err := fileWriteAll(c.outFile, alignRecordSeparators(s.toJSON(c.startName))); err != nil {
log.Fatalf(`error: %s`, err.Error())
}
case outModeTwee3, outModeTwee1:
// Write out the project as Twee source.
if _, err := fileWriteAll(c.outFile, alignRecordSeparators(s.toTwee(c.outMode))); err != nil {