tekknolagi / scrapscript

A functional, content-addressable programming language.
https://scrapscript.fly.dev/repl
Other
376 stars 10 forks source link

changed cli to use stdin and str instead of filenames #92

Closed surprisetalk closed 9 months ago

surprisetalk commented 10 months ago

The CLI currently accepts commands like this:

scrap eval file.scrap
scrap apply "1+1"
scrap yard push /tmp/yard file.scrap

I changed it to work like this:

SCRAPYARD=/tmp/scrapyard
scrap eval "1+1"
scrap apply "x->x" "1+1"
scrap yard push "x->x"

and it also works with stdin:

SCRAPYARD=/tmp/scrapyard
echo "1+1" | scrap eval
echo "1+1" | scrap apply "x->x"
echo "x->x" | scrap yard push

the previous filename behavior can be emulated like this:

SCRAPYARD=/tmp/scrapyard
scrap eval `cat file.scrap`
scrap apply `cat f.scrap` `cat x.scrap`
scrap yard push `cat file.scrap`
gregorybchris commented 10 months ago

This would be really nice to have in the main branch.. I tried to fiddle around with eval/apply stuff a lot when we first started, have always known the file pointer vs string input was wonky and wrong. Do you want to just push this to trunk?

tekknolagi commented 10 months ago

I agree--would be good to have in trunk right now. Also,

  1. you need quoting for the ...
  2. can you change README?
surprisetalk commented 9 months ago

Okay, I'll open a cleaner PR on the main branch with more documentation and "..." fixed 👍🏼