kalekundert / stepwise

Modular, command-line scientific protocols
GNU General Public License v3.0
3 stars 0 forks source link

Use JSON to communincate through pipes. #11

Closed kalekundert closed 4 years ago

kalekundert commented 4 years ago

The advantage of this is that it will provide a robust and extensible way to transfer metadata between stages of the pipeline, like:

The JSON format I'm thinking of will be something like this:

The main function would work something like this:

parse stdin as JSON
on error:
  parse stdin as a protocol
  on error:
    print the error
    save stdin

parse the command-line args as a protocol
on error:
  print the error
  save the text

if both protocols were successfully parsed:
  merge the protocols
  print the merged protocols as (text if stdout is a TTY else JSON)
else:
  concatenate the protocol strings
  print the concatenated text as (text if stdout is a TTY else JSON)