[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21698: accessing multiple flagged values with (ice-9 getopt-long)

From: Matt Wette
Subject: bug#21698: accessing multiple flagged values with (ice-9 getopt-long)
Date: Sat, 17 Oct 2015 10:05:53 -0700

This is in reference to guile-2.0.11.

The (ice-9 getopt-long) module does not provide a process for accessing multiple command line arguments.

A patch for ice-9/getopt-long.scm  is attached which adds the procedure getopt-ref/many to access multiple argument values.

The following program and results illustrate the use of the current getopt-ref and the proposed getopt-ref/many:

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 



(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))


Attachment: getopt-long.patch
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]