pact-foundation / pact-ruby-standalone

A standalone pact command line executable using the ruby pact implementation and Travelling Ruby
https://pact.io
MIT License
39 stars 32 forks source link

Request: Ability to pass json to pact-message via standard in #61

Open TimothyJones opened 3 years ago

TimothyJones commented 3 years ago

Pre issue-raising checklist

I have already (please mark the applicable with an x):

Software versions

Request

Currently, pact-message expects the content JSON to be passed as a command line parameter:

pact-message update MESSAGE_JSON --consumer=CONSUMER --pact-dir=PACT_DIR --provider=PROVIDER

JSON in a command line param is difficult to quote correctly on windows (I haven't found a library that works for all cases yet).

It would be awesome if we could work around this by having the option to pass the content via standard in:

pact-message update MESSAGE_JSON --consumer=CONSUMER --pact-dir=PACT_DIR --provider=PROVIDER
or
echo "$MESSAGE_JSON" | pact-message update --consumer=CONSUMER --pact-dir=PACT_DIR --provider=PROVIDER
TimothyJones commented 3 years ago

Here's a short test:

echo '{ "description": "a test mesage", "content": { "name": "Mary" } }' > msg
cat msg | pact-message  update --consumer=CONSUMER  --pact-dir=. --provider=PROVIDER
bethesque commented 3 years ago

Sounds good.

Why is your example in two steps instead of echo '{ "description": "a test mesage", "content": { "name": "Mary" } }' | pact-message update --consumer=CONSUMER --pact-dir=. --provider=PROVIDER ?

TimothyJones commented 3 years ago

No specific reason, just what I happened to write