mwette$ ./gotest.scm -f foo1 -b bar1 -f foo2 baz1 baz2
program arguments:
("./gotest.scm" "-f" "foo1" "-b" "bar1" "-f" "foo2" "baz1" "baz2")
getopt using option-ref:
foo: "foo2"
bar: "bar1"
getopt using option-ref/many:
foo: ("foo1" "foo2")
bar: "bar1"
mwette$ cat gotest.scm
#!/opt/local/bin/guile
!#
(use-modules (ice-9 getopt-long))
(define spec
'((foo (single-char #\f) (value #t))
(bar (single-char #\b) (value #t))))
(let* ((args (program-arguments))
(opts (getopt-long args spec)))
(simple-format #t "program arguments:\n")
(simple-format #t "~S\n" args)
(simple-format #t "\ngetopt using option-ref:\n")
(simple-format #t "foo: ~S\n" (option-ref opts 'foo #f))
(simple-format #t "bar: ~S\n" (option-ref opts 'bar #f))
(simple-format #t "\ngetopt using option-ref/many:\n")
(simple-format #t "foo: ~S\n" (option-ref/many opts 'foo #f))
(simple-format #t "bar: ~S\n" (option-ref/many opts 'bar #f))
)