diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-07-25 09:56:32 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-07-25 09:56:32 +0300 |
commit | c6230a46e93e9fb1525d5a036074aa7b5ff8a76e (patch) | |
tree | 88ad90b9f9401ae8dcac2d267853cf0143bf2103 /scheme/idest | |
parent | 0c48aa90d77dfe0868054506fb1f3aa096dd7eb8 (diff) | |
download | idest-c6230a46e93e9fb1525d5a036074aa7b5ff8a76e.tar.gz idest-c6230a46e93e9fb1525d5a036074aa7b5ff8a76e.tar.bz2 |
Implement `--format help', which shows a list of existing formats.
* scheme/idest/format/help.scm: New module.
* scheme/idest/format/framelist.scm: Define description for use by
--format help
* scheme/idest/format/lyrics.scm: Likewise.
* scheme/idest/format/shortlist.scm: Likewise.
* src/guile.c: Change priority of directory in load path:
VERSION_SITE is placed before PKG_SITE, but after user-defined
directories.
Diffstat (limited to 'scheme/idest')
-rw-r--r-- | scheme/idest/format/framelist.scm | 3 | ||||
-rw-r--r-- | scheme/idest/format/help.scm | 101 | ||||
-rw-r--r-- | scheme/idest/format/lyrics.scm | 3 | ||||
-rw-r--r-- | scheme/idest/format/shortlist.scm | 3 |
4 files changed, 110 insertions, 0 deletions
diff --git a/scheme/idest/format/framelist.scm b/scheme/idest/format/framelist.scm index 2445a59..693742e 100644 --- a/scheme/idest/format/framelist.scm +++ b/scheme/idest/format/framelist.scm @@ -18,6 +18,9 @@ (use-modules (ice-9 getopt-long)) +(define-public description + "display a list of frames defined in each file") + (define-public idest-main #f) (let* ((cmd (command-line)) diff --git a/scheme/idest/format/help.scm b/scheme/idest/format/help.scm new file mode 100644 index 0000000..4f739e6 --- /dev/null +++ b/scheme/idest/format/help.scm @@ -0,0 +1,101 @@ +;; This file is part of Idest +;; Copyright (C) 2011 Sergey Poznyakoff +;; +;; Idest 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. +;; +;; Idest 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 Idest. If not, see <http://www.gnu.org/licenses/>. + +(define-module (idest format help)) + +(use-modules (ice-9 getopt-long) + (srfi srfi-1)) + +(define (strip-suffix name) + (call-with-current-continuation + (lambda (return) + (for-each + (lambda (suf) + (if (and (not (string-null? suf)) (string-suffix? suf name)) + (return + (substring name 0 (- (string-length name) (string-length suf)))))) + %load-extensions) + (return #f)))) + +(let* ((saved-load-hook %load-hook) + (cmd (command-line)) + (progname (car cmd)) + ;; Collect a list of possible modules. List elements are conses: + ;; (basename . dir) + ;; where basename is the module name and dir is the directory where + ;; it is found. Make sure only one entry for each basename exists. + ;; Sort the list alphabetically on basename. + (candidates + (sort + (fold + (lambda (elt prev) + (catch 'misc-error + (lambda () + (let ((dir (string-append elt "/idest/format"))) + (if (and dir + (file-exists? dir) + (eq? (stat:type (stat dir)) 'directory)) + (let ((d (opendir dir))) + (let loop ((file (readdir d))) + (cond + ((not (eof-object? file)) + (if (eq? (stat:type + (stat (string-append dir "/" file))) + 'regular) + (let ((base (strip-suffix file))) + (if (and base + (not (assoc-ref prev base))) + (set! prev (cons (cons base dir) + prev))))) + (loop (readdir d))))))))) + (lambda (key . args) + #f)) + prev) + '() + %load-path) + (lambda (a b) + (string<? (car a) (car b)))))) + + ;; Try out each candidate and print ist name, directory and description + ;; if it happens to be a valid idest format module. + ;; Take care not to bail out on errors. Disable %load-hook as it migh + ;; clobber the output. + (set! %load-hook #f) + (for-each + (lambda (candidate) + (catch 'misc-error + (lambda () + (let ((mod (resolve-module + (list 'idest 'format + (string->symbol (car candidate)))))) + ; Check if it defines idest-main + (module-ref mod 'idest-main) + (format #t "~A (from ~A): ~A~%" + (car candidate) (cdr candidate) + (catch #t + (lambda () + (module-ref mod 'description)) + (lambda (key . args) + "no description"))))) + (lambda (key . args) + #f))) + candidates) + (newline) + (set! %load-hook saved-load-hook) + (exit 0)) + + + diff --git a/scheme/idest/format/lyrics.scm b/scheme/idest/format/lyrics.scm index 7fb5b1c..1ad1f03 100644 --- a/scheme/idest/format/lyrics.scm +++ b/scheme/idest/format/lyrics.scm @@ -19,6 +19,9 @@ (use-modules (ice-9 getopt-long) (ice-9 popen)) +(define-public description + "display lyrics (the USLT content), if present in the tags") + (define-public idest-main #f) (let* ((cmd (command-line)) diff --git a/scheme/idest/format/shortlist.scm b/scheme/idest/format/shortlist.scm index fb83036..4dd418b 100644 --- a/scheme/idest/format/shortlist.scm +++ b/scheme/idest/format/shortlist.scm @@ -7,6 +7,9 @@ (define-module (idest format shortlist)) +(define-public description + "display title, artist name and year, on a signle line") + (define (get-frame code frames) (or (assoc-ref (or (assoc-ref frames code) '()) |