Changeset 11148 in project


Ignore:
Timestamp:
07/03/08 14:12:49 (11 years ago)
Author:
felix winkelmann
Message:

-check and -table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • maintenance/for-each-egg.scm

    r11147 r11148  
    1212usage: csi -s for-each-egg.scm [OPTION | FILENAME ...]
    1313
    14   -help
    15   -grep TEXT
     14  -help          show this message
     15  -grep TEXT     grep egg files for TEXT
     16  -table         generate table in svnwiki syntax
     17  -check         list eggs without meta file
    1618EOF
    1719);|
     
    2527            (dir (cdr egg))
    2628            (mfile (make-pathname dir name "meta")))
    27        (when mfile
     29       (when (file-exists? mfile)
    2830         (let ((meta (car (read-file mfile))))
    29            (print "<tr><td>" egg "</td><td>" (cadr (assq 'synopsis meta)))
     31           (print "<tr><td>" (car egg) "</td><td>" (cadr (assq 'synopsis meta)))
    3032           (print "</td><td>" (cadr (assq 'author meta)) "</td><td>")
    3133           (print "    </td></tr>") ) ) ) )
    3234   dirs)
    3335  (print "</table>"))
     36
     37(define (check-meta dirs)
     38  (let ((eggs (filter-map
     39               (lambda (egg)
     40                 (let* ((name (car egg))
     41                        (dir (cdr egg))
     42                        (mfile (make-pathname dir name "meta")))
     43                   (and (file-exists? mfile)
     44                        name)))
     45               dirs)))
     46    (for-each
     47     print
     48     (sort (lset-difference equal? (directory) *special* eggs) string<?))))
     49
     50(define ((grep-files text) dirs)
     51  (for-each
     52   (lambda (dir)
     53     (system "grep -rHu '" text "' '" (cdr dir) "'"))
     54   dirs))
    3455
    3556(define *eggs*
     
    3859      (() '())
    3960      (("-help" . _) (usage 0))
     61      (("-check" . more)
     62       (set! *command* check-meta)
     63       (loop more))
    4064      (("-table" . more)
    4165       (set! *command* generate-table)
    4266       (loop more))
    4367      (("-grep" text . more)
    44        (set! *command*
    45          (let ((old *command*))
    46            (lambda (dir)
    47              (old dir)
    48              (system (string-append "grep '" text "' '" dir "/*'")) )))
     68       (set! *command* (grep-files text))
    4969       (loop more))
    5070      ((egg . more)
     71       (when (char=? #\- (string-ref egg 0))
     72         (usage 1))
    5173       (cons egg (loop more))))))
    5274
Note: See TracChangeset for help on using the changeset viewer.