@@ 0,0 1,25 @@
+#!/usr/bin/env elvish
+# usage:
+# ./outlinestats.elv docs.example.com ol_api_xyz123
+
+use str
+
+var outlineInstance = $args[0]
+var apiKey = $args[1]
+
+var words = 0
+var chars = 0
+
+var documents = (curl -sL -X 'POST' -H 'authorization: Bearer '$apiKey ^
+ -H 'content-type: application/json' -H 'accept: application/json' ^
+ -d '{"offset": 0, "limit": 100}' 'https://'$outlineInstance'/api/documents.list')
+
+var data = (echo $documents | from-json)[data]
+
+each {|doc|
+ set words = (+ $words (str:split ' ' $doc[text] | count))
+ set chars = (+ $chars (str:split '' $doc[text] | count))
+} $data
+
+printf "words: %g\nchars: %g\n" $words $chars
+