accordproject / template-archive

Smart Legal Contracts & Templating System
https://accordproject.org/projects/cicero/
Apache License 2.0
280 stars 119 forks source link

The "cicero trigger" command does not support "data.json" #681

Closed martinhalford closed 3 years ago

martinhalford commented 3 years ago

Bug Report 🐛

There are two ways to populate data into a Cicero Template. Either via a sample.md file or a data.json file. The cicero trigger only supports sample.md.

Expected Behavior

Would expect the following to be a valid command.

cicero trigger --state ./state.json --request ./request.json --data ./data.json

Current Behavior

If no sample.md provided then get error:

ERROR: A text/sample.md file is required. Try the --sample flag or create a text/sample.md in your template.

Possible Solution

Add CLI option --data which accepts a data.json file as data input to the template. In many ways, this is cleaner than having to parse a sample.md file first that then produces the data payload.

Detailed Description

The problem is exacerbated when there is heavy use of {{% %}} and --unquotevariables. In this case, Cicero does not always produce sample.md files that can be validly parsed by Cicero. This means it's not possible to use the cicero trigger command in these scenarios. :-(