aboutsummaryrefslogtreecommitdiff
path: root/examples/dry-run.scm
blob: d6b07ab66463a1151012f002ab27ae3d0b3563dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
;; echo.scm - test another Idest script.
;; Copyright (C) 2011 Sergey Poznyakoff
;; License GPLv3+: GNU GPL version 3 or later
;;  <http://gnu.org/licenses/gpl.html>
;; This is free software: you are free to change and redistribute it.
;; There is NO WARRANTY, to the extent permitted by law.

(let* ((cmd (command-line))
       (progname (car cmd)))
  (set! %load-hook (lambda (filename)
		     (format #t "~A: loading ~a ...\n"
			     progname filename)))
  (cond
   ((< (length cmd) 3)
    (format (current-error-port) "usage: idest -S ~A SCRIPT FILE...~%"
	    progname)
    (exit 1))
   (else
    (let ((file-name (list-ref cmd 1)))
      (set-program-arguments (cons (car cmd) (list-tail cmd 2)))
      (primitive-load-path file-name)
      (cond
       (idest-readonly
	(format (current-error-port)
		"~A: info: ~A does not modify frames~%" progname file-name))
       ((catch #t
	       (lambda ()
		 (procedure? idest-main))
	       (lambda (key . args)
		 #f))
	(set! idest-readonly #t)
	(let ((main-func idest-main))
	  (set! idest-main
		(lambda (file frames)
		  (let ((result (main-func file frames)))
		    (format #t "File ~A ~A~%" file result))))))
       (else
	(format (current-error-port)
		"~A: idest-main is not defined in ~A~%" progname file-name)
	(exit 1)))))))

Return to:

Send suggestions and report system problems to the System administrator.