File: std-args.scm

package info (click to toggle)
gwave 20031224-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,508 kB
  • ctags: 1,065
  • sloc: ansic: 8,029; lisp: 1,619; sh: 1,202; makefile: 167
file content (85 lines) | stat: -rw-r--r-- 2,255 bytes parent folder | download | duplicates (2)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;
; module providing gwave's standard command-line argument parsing.
;

(define-module (app gwave std-args)
  :use-module (ice-9 getopt-long)
  :use-module (ice-9 common-list)
  :use-module (app gwave cmds)
  :use-module (app gwave export)
)

(debug-enable 'debug)
(read-enable 'positions)

(dbprint "std-args.scm running\n")

;
; Note: so long as there is still a getopt(3) call in gwave.c, 
; we have to be sure all options are listed both places.
;
; TODO:  better checking of option arguments;
;  make sure numeric ones are numbers, and within valid range. 
;
(define opts (getopt-long (program-arguments)
             `((nobacktrace  (single-char #\n))
               (panels       (single-char #\p) (value #t))
               (script       (single-char #\s) (value #t))
	       (verbose      (single-char #\v))
	       (debug        (single-char #\x))
	       )))

(define verbose
  (let ((a (assq 'verbose opts)))
    (if a
        (cdr a)
        #f)))

(let ((a (assq 'panels opts)))
    (if a
        (set! initial-panels (string->number (cdr a)))))

(define startup-script #f)
(let ((s (assq 'script opts)))
    (if s
	(if (string? (cdr s))
	    (set! startup-script (cdr s)))))

(define cmdline-files (pick string? (assq '() opts)))

;(display "opts:") (display opts) (newline)
;(display "script:") (display startup-script)(newline)
;(display "args: verbose=")(display verbose)
;(display " npanels=")(display npanels)
;(display " files=")
;(for-each (lambda (f) 
;	    (begin (display f) (display " ")))
;	    cmdline-files)
;(newline)

;
; wave window hook to load files listed on the command line and
; create initial panels.
; We use append-hook so that the menubar is already created; this way
; the view->variable list menu item works properly for these.

(append-hook! 
 new-wavewin-hook
 (lambda ()
   (dbprint "in std-args new-wavewin-hook\n")
   ; load files listed on the command line
   (for-each (lambda (f)
	       (load-wavefile! f)) 
	     cmdline-files)

   ; add the initial set of panels
   (do ((i 0 (+ i 1))) ((>= i initial-panels))
     (wtable-insert-typed-panel! #f default-wavepanel-type))

   ; execute script specified with -s 
   (if startup-script
       (load startup-script))
))


(dbprint "std-args.scm done\n")