aboutsummaryrefslogtreecommitdiff
path: root/scheme/idest
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-01 00:42:16 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-01 01:31:32 +0300
commit284a1ac48b35ef107979978fd443fbde6a6b4b12 (patch)
tree126db7b2837559bd678fb976f2cda43ccbac4e0a /scheme/idest
parent9a64ffcf42132cf27fdd5a59127985f1175234c3 (diff)
downloadidest-284a1ac48b35ef107979978fd443fbde6a6b4b12.tar.gz
idest-284a1ac48b35ef107979978fd443fbde6a6b4b12.tar.bz2
Finish the docs.
* doc/.gitignore: Update. * doc/idest.texi: Document all new features. * scheme/idest/batch/setlyrics.scm: Update --help output. * scheme/idest/batch/setpic.scm: Likewise. * scheme/idest/format/lyrics.scm: Likewise. * scheme/idest/format/pic.scm: Likewise. * scheme/idest/list-modules.scm: Implement the --which option. * src/guile.c (%idest-package-site-dir) (%idest-version-site-dir) (%idest-guile-site-dir): New functions.
Diffstat (limited to 'scheme/idest')
-rw-r--r--scheme/idest/batch/setlyrics.scm1
-rw-r--r--scheme/idest/batch/setpic.scm1
-rw-r--r--scheme/idest/format/lyrics.scm1
-rw-r--r--scheme/idest/format/pic.scm1
-rw-r--r--scheme/idest/list-modules.scm154
5 files changed, 95 insertions, 63 deletions
diff --git a/scheme/idest/batch/setlyrics.scm b/scheme/idest/batch/setlyrics.scm
index bd137a5..b41cb5b 100644
--- a/scheme/idest/batch/setlyrics.scm
+++ b/scheme/idest/batch/setlyrics.scm
@@ -25,6 +25,7 @@
(format #t " -f, --file FILE read text from FILE (default: stdin)\n")
(format #t " -l, --lang NAME set language in which the lyrics is writen (default: eng)\n")
(format #t " -c, --content TEXT set content description\n")
+ (format #t " -h, --help show this help summary\n")
(exit 0))
(define-public description
diff --git a/scheme/idest/batch/setpic.scm b/scheme/idest/batch/setpic.scm
index 3691ad2..c0670a3 100644
--- a/scheme/idest/batch/setpic.scm
+++ b/scheme/idest/batch/setpic.scm
@@ -71,6 +71,7 @@
(format #t " -m, --mime-type TYPE set MIME type\n")
(format #t " -p, --pic-type NUM set picture type\n")
(format #t " -f, --file FILE read picture from FILE\n")
+ (format #t " -h, --help show this help summary\n")
(newline)
(exit 0))
(else
diff --git a/scheme/idest/format/lyrics.scm b/scheme/idest/format/lyrics.scm
index 3e366fd..8b7bf9e 100644
--- a/scheme/idest/format/lyrics.scm
+++ b/scheme/idest/format/lyrics.scm
@@ -50,6 +50,7 @@
(format #t "OPTIONS are:\n")
(format #t " -l, --lang NAME set language in which the lyrics is writen (default: eng)\n")
(format #t " -c, --content TEXT set content description\n")
+ (format #t " -h, --help show this help summary\n")
(exit 0))
(else
(set-program-arguments (cons progname (cdr x))))))
diff --git a/scheme/idest/format/pic.scm b/scheme/idest/format/pic.scm
index 29f658b..d1fbc8b 100644
--- a/scheme/idest/format/pic.scm
+++ b/scheme/idest/format/pic.scm
@@ -129,6 +129,7 @@
(format #t " -m, --mime-type TYPE picture must have this MIME type\n")
(format #t " -s, --store store picture on disk, don't show it\n")
(format #t " -f, --file FILE save picture to FILE (implies --store)\n")
+ (format #t " -h, --help show this help summary\n")
(newline)
(format #t "FILE is a format string and can contain the following meta-sequences:\n\n")
(format #t "Sequence Expands to\n")
diff --git a/scheme/idest/list-modules.scm b/scheme/idest/list-modules.scm
index bd538ea..c69d331 100644
--- a/scheme/idest/list-modules.scm
+++ b/scheme/idest/list-modules.scm
@@ -31,70 +31,98 @@
(return #f))))
(define-public (idest-list-modules type)
- (let ((saved-load-hook %load-hook)
- ;; 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/"
- (symbol->string type))))
- (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))))))
+ (let ((progname (car (command-line)))
+ (grammar `((which (single-char #\w))))
+ (print-dir #f))
+ (catch 'misc-error
+ (lambda ()
+ (for-each
+ (lambda (x)
+ (case (car x)
+ ((which)
+ (set! print-dir #t))
+ (else
+ (set-program-arguments (cons progname (cdr x))))))
+ (getopt-long (command-line) grammar)))
+ (lambda (key . args)
+ (with-output-to-port
+ (current-error-port)
+ (lambda ()
+ (format #t "~A: " progname)
+ (apply format #t (list-ref args 1) (list-ref args 2))
+ (newline)
+ (exit 1)))))
- ;; 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 type
- (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)))
+ (let ((saved-load-hook %load-hook)
+ ;; 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/"
+ (symbol->string type))))
+ (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 type
+ (string->symbol (car candidate))))))
+ ; Check if it defines idest-main
+ (module-ref mod 'idest-main)
+ ; Print module name
+ (display (car candidate))
+ ; Its directory, if required
+ (if print-dir
+ (format #t " (~A)" (cdr candidate)))
+ ; A colon, and description (if any
+ (format #t ": ~A~%"
+ (catch #t
+ (lambda ()
+ (module-ref mod 'description))
+ (lambda (key . args)
+ "no description")))))
+ (lambda (key . args)
+ #f)))
+ candidates)
+ (newline)
+ (set! %load-hook saved-load-hook))))

Return to:

Send suggestions and report system problems to the System administrator.