CLI with text output
Closed this issue · 4 comments
I love this.
Could you add txt as an output type for the CLI? Or even console?
That would allow me to use a function in Observable with a notebook like this:
https://observablehq.com/@cobus/prerender-test
Yo thanks for the feature request! This seems totally reasonable. It seems like adding a new --stdout
flag and --format text
option would be best, like this:
# Write output to sample.txt
$ observable-prerender @cobus/pretender-test output \
--redefine inputData:bbb
--format text --out sample.txt
# Write output to stdout
$ observable-prerender @cobus/pretender-test output \
--redefine inputData:bbb
--format text --stdout
I've got a couple changes/features coming in soon along with this, so may take some time until I get this feature in. As a workaround, you can create a script that uses the node API to do what you want (which you have in that notebook).
That would be awesome!
Thanks
Update: v0.3.0
Now has this functionality. If you pass in "-"
as the output file name, it will print the data to stdout
. --format txt
or --format text
is an option as well.
For your example:
$ observable-prerender @cobus/prerender-test output --redefine inputData:yoo --format txt --out -
You passed in yoo
To update your observable-prerender
version:
npm i -g @alex.garcia/observable-prerender@v0.3.0
Let me know if it works! Planning to add some --format json
and other misc options soon as well.
Awesome. It works!!!