mirror of https://github.com/djcb/mu.git
* guile: add support for scripts
This commit is contained in:
parent
6d19880ced
commit
c1828ab2c8
|
@ -1,4 +1,4 @@
|
|||
## Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
## Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
##
|
||||
## 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
|
||||
|
@ -19,6 +19,10 @@ include $(top_srcdir)/gtest.mk
|
|||
# FIXME: GUILE_SITEDIR would be better, but that
|
||||
# breaks 'make distcheck'
|
||||
scmdir=${prefix}/share/guile/site/2.0/mu/
|
||||
scm_DATA=stats.scm plot.scm
|
||||
|
||||
scm_DATA= \
|
||||
stats.scm \
|
||||
plot.scm \
|
||||
script.scm
|
||||
|
||||
EXTRA_DIST=$(scm_DATA)
|
||||
|
|
|
@ -33,18 +33,18 @@ return the file name."
|
|||
(close output)
|
||||
datafile))
|
||||
|
||||
(define* (mu:plot data title x-label y-label #:optional (ascii #f))
|
||||
"Plot DATA with TITLE, X-LABEL and X-LABEL. If ASCII is true, display
|
||||
using raw text, otherwise, use a graphical window."
|
||||
(define* (mu:plot data title x-label y-label #:optional (text-only #f))
|
||||
"Plot DATA with TITLE, X-LABEL and X-LABEL. If TEXT-ONLY is true,
|
||||
display using raw text, otherwise, use a graphical window."
|
||||
(let ((datafile (export-pairs data))
|
||||
(gnuplot (open-pipe "gnuplot -p" OPEN_WRITE)))
|
||||
(display (string-append
|
||||
"reset\n"
|
||||
"set term " (if ascii "dumb" "wxt") "\n"
|
||||
"set term " (if text-only "dumb" "wxt") "\n"
|
||||
"set title \"" title "\"\n"
|
||||
"set xlabel \"" x-label "\"\n"
|
||||
"set ylabel \"" y-label "\"\n"
|
||||
"set boxwidth 0.9\n"
|
||||
"plot \"" datafile "\" using 2:xticlabels(1) with boxes fs solid\n")
|
||||
gnuplot)
|
||||
(close-pipe gnuplot)))
|
||||
(close-pipe gnuplot)))
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
;; Copyright (C) 2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
;;
|
||||
;; 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, 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.
|
||||
(define-module (mu script)
|
||||
:export (mu:run mu:text-only))
|
||||
|
||||
(use-modules (ice-9 getopt-long) (ice-9 optargs) (ice-9 popen) (ice-9 format))
|
||||
(use-modules (mu) (mu stats) (mu plot))
|
||||
|
||||
(define (help-and-exit)
|
||||
"Show some help."
|
||||
(format #t "usage: script [--help] [--textonly] "
|
||||
"[--muhome=<muhome>] [searchexpr]\n")
|
||||
(exit 0))
|
||||
|
||||
(define (mu:run args func)
|
||||
"Interpret argument-list ARGS (like command-line
|
||||
arguments). Possible arguments are:
|
||||
--help (show some help and exit)
|
||||
--muhome (path to alternative mu home directory)
|
||||
--textonly (don't show any graphical windows)
|
||||
searchexpr (a search query)
|
||||
then call FUNC with args SEARCHEXPR and TEXTONLY."
|
||||
(setlocale LC_ALL "")
|
||||
(let* ((optionspec '( (muhome (value #t))
|
||||
(what (value #t))
|
||||
(textonly (value #f))
|
||||
(help (single-char #\h) (value #f))))
|
||||
(options (getopt-long args optionspec))
|
||||
(help (option-ref options 'help #f))
|
||||
(textonly (option-ref options 'textonly #f))
|
||||
(muhome (option-ref options 'muhome #f))
|
||||
(restargs (option-ref options '() #f))
|
||||
(expr (if restargs (string-join restargs) "")))
|
||||
(if help (help-and-exit))
|
||||
(mu:initialize muhome)
|
||||
(func expr textonly)))
|
||||
|
||||
;; Local Variables:
|
||||
;; mode: scheme
|
||||
;; End:
|
|
@ -16,8 +16,12 @@
|
|||
|
||||
include $(top_srcdir)/gtest.mk
|
||||
|
||||
EXTRA_DIST= \
|
||||
msg-stats.scm
|
||||
EXTRA_DIST= \
|
||||
msgs-per-year.scm \
|
||||
msgs-per-hour.scm \
|
||||
msgs-per-month.scm \
|
||||
msgs-per-day.scm \
|
||||
msgs-per-year-month.scm
|
||||
|
||||
muguiledistscriptdir = $(datadir)/$(PACKAGE)/scripts/stats
|
||||
muguiledistscriptdir = $(pkgdatadir)/scripts/stats
|
||||
muguiledistscript_SCRIPTS = $(EXTRA_DIST)
|
||||
|
|
Loading…
Reference in New Issue