This repository has been archived by the owner on Apr 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Scripting
Yuri Schimke edited this page Jul 18, 2018
·
13 revisions
OkUrl builds on the javascript support (jjs) in Java 8 to support interactive scripting (repl) and shell scripts.
As well as existing functionality https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions, https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/shell.html
Additions bindings are exposed
- readParam(name) - performs standard param handling, currently '@path/filename.txt' is read and replaces the param.
- query(url) - query a webservice and parse JSON response
- location() - reads OSX Core Location. This requires "brew install corelocationcli"
$ okshell
jjs> var ab = query("https://api.twitter.com/1.1/statuses/home_timeline.json");
jjs> ab.filter(function(tweet) {
return tweet.user.screen_name == 'GuardianAus';
}).map(function(tweet) {
return tweet.text;
});
My husband never pays me compliments – it upsets me a lot but he won’t change his ways https://t.co/Ec5qBoTcXb
#!/usr/bin/env okshell
var loc = location();
var a = query('https://api.uber.com/v1/products?latitude=${loc.latitude}&longitude=${loc.longitude}')
print(a.products[0]);