From 71b01c6ff28fd2132bdbb7c495b3953bc3fc7270 Mon Sep 17 00:00:00 2001 From: djcb Date: Wed, 14 Dec 2011 09:12:10 +0200 Subject: [PATCH] * added an example guile script --- guile/examples/Makefile.am | 20 ++++++++++++++++++++ guile/examples/mu-msg-stats | 30 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 guile/examples/Makefile.am create mode 100755 guile/examples/mu-msg-stats diff --git a/guile/examples/Makefile.am b/guile/examples/Makefile.am new file mode 100644 index 00000000..c7aad29c --- /dev/null +++ b/guile/examples/Makefile.am @@ -0,0 +1,20 @@ +## Copyright (C) 2011 Dirk-Jan C. Binnema +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software Foundation, +## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +include $(top_srcdir)/gtest.mk + +noinst_DIST= \ + mu-msg-stats diff --git a/guile/examples/mu-msg-stats b/guile/examples/mu-msg-stats new file mode 100755 index 00000000..cce36ce4 --- /dev/null +++ b/guile/examples/mu-msg-stats @@ -0,0 +1,30 @@ +#!/bin/sh +exec guile -e main -s $0 $@ +!# + +(use-modules (mu) (mu stats)) + +(define (main args) + + (define (usage-exit) + (display "usage: mu-msg-stats hour|day|month|year [searchexpr]") + (newline) + (exit 1)) + + (if (not (>= (length args) 2)) + (usage-exit)) + + (mu:init) + + (let* ((lst (cdr (cdr args))) + (expr (if lst (string-join lst) ""))) + (display expr) + (newline) + (cond + ((string= (cadr args) "hour") (mu:plot:per-hour expr)) + ((string= (cadr args) "day") (mu:plot:per-weekday expr)) + ((string= (cadr args) "month") (mu:plot:per-month expr)) + ((string= (cadr args) "year") (mu:plot:per-year expr)) + (else (usage-exit))))) + +