#!/bin/bash
# https://docs.sheetjs.com/docs/demos/engines/v8

cd /tmp
rm -rf sheetjs2csv
mkdir sheetjs2csv
cd sheetjs2csv

curl -o Cargo.toml https://docs.sheetjs.com/cli/Cargo.toml
curl -o snapshot.rs https://docs.sheetjs.com/cli/snapshot.rs
curl -o sheet2csv.rs https://docs.sheetjs.com/cli/sheet2csv.rs

curl -o xlsx.full.min.js https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js
curl -o xlsx.zahl.js https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.zahl.js
curl -o pres.numbers https://docs.sheetjs.com/pres.numbers

cargo build --bin snapshot
cargo run --bin snapshot

cargo build --release --bin sheet2csv; echo $?

mv target/release/sheet2csv .
./sheet2csv pres.numbers; echo $?