#! ./pre-inst-env !# (use-modules (ice-9 format) (ice-9 futures) (ice-9 getopt-long) (ice-9 ftw)) (let* ((option-spec '((settings (single-char #\s) (value #t)) (output (single-char #\o) (value #t)) (documentation (single-char #\d) (value #t)))) (options (getopt-long (command-line) option-spec)) (settings (option-ref options 'settings #f)) (output (option-ref options 'output #f)) (documentation (option-ref options 'documentation #f))) (define (enter? name stat result) stat result ;ignore ;; Skip version control directories if any. (not (member (basename name) '(".git" ".svn" "CVS")))) (define (leaf name stat result) stat result ;ignore (when (string-suffix? ".scm" name) (let* ((base-file-name (basename name ".scm")) (cmd (format #f " ~a --settings ~a --output ~a --documentation ~a" name settings (string-append output "/" base-file-name ".ttl") (string-append documentation "/" base-file-name ".md")))) (unless (string? base-file-name "dataset-metadata-git") (touch (future (begin (display (format #f "Running ~a" cmd)) (display "\n") (system cmd)))))))) (define (down name stat result) name stat ;ignore result) (define (up name stat result) name stat ;ignore result) (define (skip name stat result) name stat ;ignore result) ;; Ignore unreadable files/directories but warn the user. (define (error name stat errno result) stat ;ignore (format (current-error-port) "warning: ~a: ~a~%" name (strerror errno)) result) (file-system-fold enter? leaf down up skip error 0 ;initial counter is zero bytes "./examples"))