summaryrefslogtreecommitdiffstats
path: root/src/scripts/journald-url-handler.lnav
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/scripts/journald-url-handler.lnav33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/scripts/journald-url-handler.lnav b/src/scripts/journald-url-handler.lnav
new file mode 100644
index 0000000..904237c
--- /dev/null
+++ b/src/scripts/journald-url-handler.lnav
@@ -0,0 +1,33 @@
+#
+# @synopsis: journald-url-handler
+# @description: Internal script to handle opening journald URLs
+#
+
+;SELECT
+ jget(url, '/scheme') AS jscheme,
+ jget(url, '/host') AS jhost,
+ jget(url, '/parameters') as jparams
+ FROM (SELECT parse_url($1) AS url)
+
+;SELECT
+ printf(':sh journalctl --output=json -f %s %s',
+ CASE $jhost
+ WHEN 'localhost' THEN
+ ''
+ ELSE
+ '-m ' || $jhost
+ END,
+ (SELECT group_concat(
+ CASE length(key)
+ WHEN 1 THEN
+ '-' || key || ' '
+ ELSE
+ '--' || key || '='
+ END ||
+ value,
+ ' ')
+ FROM json_each($jparams)
+ )
+ ) AS cmds
+
+:eval ${cmds}