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

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 24 Jun 2016 17:15:01 +0000

Your bug report

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

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
21698: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21698
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#21698: accessing multiple flagged values with (ice-9 getopt-long)
From: Andy Wingo <[email-masked]>
To: [email-masked] (Ludovic Courtès)
Cc: [email-masked], Matt Wette <[email-masked]>
Date: Fri, 24 Jun 2016 19:14:28 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On Fri 24 Jun 2016 17:30, [email-masked] (Ludovic Courtès) writes:

> Andy Wingo <[email-masked]> skribis:
>
>> Thanks for the patch.  My instinct however is to point you towards
>> SRFI-37, which in addition to supporting multiple argument values can
>> also be used to fold over the precise argument order.  I just don't know
>> that we should be expanding (ice-9 getopt-long); it has its use case and
>> if your needs go beyond it, then probably your needs go way beyond it.
>>
>>   https://www.gnu.org/software/guile/manual/html_node/SRFI_002d37.html
>>
>> Ludovic, second opinions?
>
> Seconded.  I think we should probably “freeze” (ice-9 getopt-long) and
> recommend SRFI-37.

Okeydoke, closing.  Thanks!

Andy

Subject: accessing multiple flagged values with (ice-9 getopt-long)
From: Matt Wette <[email-masked]>
To: [email-masked]
Cc: Matthew Wette <[email-masked]>
Date: Sat, 17 Oct 2015 10:05:53 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

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"

where

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