#!/usr/bin/env bash
set -euo pipefail

cargo run -- \
  query \
  --input ./examples/inventory.xlsx \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products.txt

cargo run -- \
  query \
  --input ./examples/inventory.xlsx \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products.csv \
  --format csv

cargo run -- \
  query \
  --input ./examples/inventory.xlsx \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products.jsonl \
  --format jsonl

cargo run -- \
  query \
  --input ./examples/inventory.xlsx \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products.md \
  --format markdown

cargo run -- \
  query \
  --input ./examples/inventory.xlsx \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products.xml \
  --format xml

cargo run -- \
  query \
  --input ./examples/inventory.xlsx \
  --sql "SELECT category, SUM(stock) AS total_stock FROM table GROUP BY category ORDER BY total_stock DESC" \
  --output ./examples/stock-by-category.xlsx \
  --format xlsx

cargo run -- \
  query \
  --input ./examples/inventory.xml:Inventory \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products-from-xml.csv \
  --format csv

cargo run -- \
  query \
  --input ./examples/inventory.csv \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products-from-csv.csv \
  --format csv

cargo run -- \
  query \
  --input ./examples/inventory.jsonl \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products-from-jsonl.csv \
  --format csv

cargo run -- \
  query \
  --input ./examples/inventory.json:Inventory \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products-from-json.csv \
  --format csv

cargo run -- \
  query \
  --input ./examples/inventory.md \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products-from-markdown.csv \
  --format csv

cargo run -- \
  query \
  --input ./examples/inventory.html \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products-from-html.csv \
  --format csv

cargo run -- \
  query \
  --input ./examples/inventory.xlsx \
  --sql "SELECT product, price FROM table WHERE active = 1 ORDER BY price DESC" \
  --output ./examples/active-products.html \
  --format html
