From unknown Tue Aug 19 12:51:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21698: accessing multiple flagged values with (ice-9 getopt-long) Resent-From: Matt Wette Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 17 Oct 2015 18:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21698 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 21698@debbugs.gnu.org Cc: Matthew Wette X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.144510649028996 (code B ref -1); Sat, 17 Oct 2015 18:29:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Oct 2015 18:28:10 +0000 Received: from localhost ([127.0.0.1]:54605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZnWDB-0007Xb-AI for submit@debbugs.gnu.org; Sat, 17 Oct 2015 14:28:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54872) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZnUvz-0005di-81 for submit@debbugs.gnu.org; Sat, 17 Oct 2015 13:06:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnUvy-0008QO-1A for submit@debbugs.gnu.org; Sat, 17 Oct 2015 13:06:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUvx-0008QK-U4 for submit@debbugs.gnu.org; Sat, 17 Oct 2015 13:06:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUvx-0004Ig-16 for bug-guile@gnu.org; Sat, 17 Oct 2015 13:06:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnUvt-0008Ps-03 for bug-guile@gnu.org; Sat, 17 Oct 2015 13:06:16 -0400 Received: from vms173025pub.verizon.net ([206.46.173.25]:52141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUvs-0008Ph-Fq for bug-guile@gnu.org; Sat, 17 Oct 2015 13:06:12 -0400 Received: from [192.168.2.127] ([72.87.204.128]) by vms173025.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0NWD009H2JHVGUC0@vms173025.mailsrvcs.net> for bug-guile@gnu.org; Sat, 17 Oct 2015 12:05:56 -0500 (CDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=WpDWSorv c=1 sm=1 tr=0 a=Jf1g6iwM2K3MHzQE8uPn/Q==:117 a=o1OHuDzbAAAA:8 a=oR5dmqMzAAAA:8 a=5lJygRwiOn0A:10 a=2uEN-48ru5wOoboNUTwA:9 a=CjuIK1q_8ugA:10 a=hZV0AYy1jCtPVrdHdrEA:9 a=l57CAgH5AiQDqgUi:21 a=_W_S_7VecoQA:10 a=QpKWWIOaL3wNxZuwVIAA:9 a=boEB8yKzicCxs0FBlv8A:9 From: Matt Wette Content-type: multipart/alternative; boundary="Apple-Mail=_D42C07B0-EF94-4EA9-82E5-B3C94F8D9D47" Date: Sat, 17 Oct 2015 10:05:53 -0700 Message-id: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> MIME-version: 1.0 (Mac OS X Mail 8.2 \(2104\)) X-Mailer: Apple Mail (2.2104) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Mailman-Approved-At: Sat, 17 Oct 2015 14:28:08 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) --Apple-Mail=_D42C07B0-EF94-4EA9-82E5-B3C94F8D9D47 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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=20 #!/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)) ) --Apple-Mail=_D42C07B0-EF94-4EA9-82E5-B3C94F8D9D47 Content-Type: multipart/mixed; boundary="Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB" --Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii 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))

  )

= --Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB Content-Disposition: attachment; filename=getopt-long.patch Content-Type: application/octet-stream; name="getopt-long.patch" Content-Transfer-Encoding: 7bit *** getopt-long.scm-orig 2015-10-15 06:40:29.000000000 -0700 --- getopt-long.scm 2015-10-17 09:42:41.000000000 -0700 *************** *** 154,159 **** --- 154,173 ---- ;;; (option-ref (getopt-long ...) 'x-includes 42) => "/usr/include" ;;; (option-ref (getopt-long ...) 'not-a-key! 31) => 31 + ;;; (option-ref/many OPTIONS KEY DEFAULT) + ;;; Return value in alist OPTIONS using KEY, a symbol; or DEFAULT if not + ;;; found. If multiple arg-options provided a list is returned. The value + ;;; is either a string, a list or `#t'. + ;;; + ;;; For example, if the above was executed with multiple x-includes flags, + ;;; then all will be returned in a list: + ;;; + ;;; (getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include" + ;;; "--x-includes=/opt/includd" "--" "-fred" "foo2" "foo3") + ;;; grammar) + ;;; (option-ref/many (getopt-long ...) 'x-includes 42) + ;;; => ("/usr/include" "/opt/include") + ;;; Code: (define-module (ice-9 getopt-long) *************** *** 162,168 **** #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 optargs) ! #:export (getopt-long option-ref)) (define %program-name (make-fluid "guile")) (define (program-name) --- 176,182 ---- #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 optargs) ! #:export (getopt-long option-ref option-ref/many)) (define %program-name (make-fluid "guile")) (define (program-name) *************** *** 368,371 **** --- 382,397 ---- The value is either a string or `#t'." (or (assq-ref options key) default)) + (define (option-ref/many options key default) + "Return value, or values, in alist OPTIONS using KEY, a symbol; or DEFAULT if not found. + The value is either a string, a list or `#t'." + (let loop ((rez #f) (opts options)) + (if (null? opts) (or rez default) + (if (eq? key (caar opts)) + (cond + ((pair? rez) (loop (cons (cdar opts) res) (cdr opts))) + (rez (loop (list (cdar opts) rez) (cdr opts))) + (else (loop (cdar opts) (cdr opts)))) + (loop rez (cdr opts)))))) + ;;; getopt-long.scm ends here --Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
--Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB-- --Apple-Mail=_D42C07B0-EF94-4EA9-82E5-B3C94F8D9D47-- From unknown Tue Aug 19 12:51:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21698: accessing multiple flagged values with (ice-9 getopt-long) Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 24 Jun 2016 14:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21698 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Matt Wette Cc: ludo@gnu.org, 21698@debbugs.gnu.org Received: via spool by 21698-submit@debbugs.gnu.org id=B21698.146678003719621 (code B ref 21698); Fri, 24 Jun 2016 14:54:02 +0000 Received: (at 21698) by debbugs.gnu.org; 24 Jun 2016 14:53:57 +0000 Received: from localhost ([127.0.0.1]:54436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGSUW-00056O-KM for submit@debbugs.gnu.org; Fri, 24 Jun 2016 10:53:56 -0400 Received: from pb-sasl2.pobox.com ([64.147.108.67]:61541 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGSUV-00056G-IB for 21698@debbugs.gnu.org; Fri, 24 Jun 2016 10:53:55 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 3D42B21F38; Fri, 24 Jun 2016 10:53:54 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=ErUm83TP+TjZKGNvSYIoiWtnM+k=; b=HlCH7H ZwUZ4PSPPhysip33EYCq/URq1rPRySnkhIiKeBDMNOeRMZqfPfpgxCOxxDWIYhVt j3HvoQ/A1APo55mlyeNMNveNJRcAeJiWLgSZpuHnm3hUee72K87aukeA21mJr2hR 62Oawu197MqKs1fBNP/MkBAaj2ilbc60IzJFw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=VrppGeCEvEVsFr7eYUYni2EV91wXezBf 1w/tgHj5tvjziv4gmRUumGVZRJ8vu5yD8Hu7JSB9outopD2bg5iD+ray2y+Lsrao ShNDXzvyIiBeBbKnHKPY8Di2mOd5Ie1eBiwDbCp31woL8ha6NjU9+fuzqX45bgvc VlBaNgvy5uc= Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 3509221F35; Fri, 24 Jun 2016 10:53:54 -0400 (EDT) Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id 37DC221F34; Fri, 24 Jun 2016 10:53:53 -0400 (EDT) From: Andy Wingo References: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> Date: Fri, 24 Jun 2016 16:53:46 +0200 In-Reply-To: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> (Matt Wette's message of "Sat, 17 Oct 2015 10:05:53 -0700") Message-ID: <878txufxj9.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 781AB62E-3A1B-11E6-AF8A-28A6F1301B6D-02397024!pb-sasl2.pobox.com X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) Hi Matt, 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? Andy On Sat 17 Oct 2015 19:05, Matt Wette writes: > 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)) > > ) > > > > *** getopt-long.scm-orig 2015-10-15 06:40:29.000000000 -0700 > --- getopt-long.scm 2015-10-17 09:42:41.000000000 -0700 > *************** > *** 154,159 **** > --- 154,173 ---- > ;;; (option-ref (getopt-long ...) 'x-includes 42) => "/usr/include" > ;;; (option-ref (getopt-long ...) 'not-a-key! 31) => 31 > > + ;;; (option-ref/many OPTIONS KEY DEFAULT) > + ;;; Return value in alist OPTIONS using KEY, a symbol; or DEFAULT if not > + ;;; found. If multiple arg-options provided a list is returned. The value > + ;;; is either a string, a list or `#t'. > + ;;; > + ;;; For example, if the above was executed with multiple x-includes flags, > + ;;; then all will be returned in a list: > + ;;; > + ;;; (getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include" > + ;;; "--x-includes=/opt/includd" "--" "-fred" "foo2" "foo3") > + ;;; grammar) > + ;;; (option-ref/many (getopt-long ...) 'x-includes 42) > + ;;; => ("/usr/include" "/opt/include") > + > ;;; Code: > > (define-module (ice-9 getopt-long) > *************** > *** 162,168 **** > #:use-module (ice-9 match) > #:use-module (ice-9 regex) > #:use-module (ice-9 optargs) > ! #:export (getopt-long option-ref)) > > (define %program-name (make-fluid "guile")) > (define (program-name) > --- 176,182 ---- > #:use-module (ice-9 match) > #:use-module (ice-9 regex) > #:use-module (ice-9 optargs) > ! #:export (getopt-long option-ref option-ref/many)) > > (define %program-name (make-fluid "guile")) > (define (program-name) > *************** > *** 368,371 **** > --- 382,397 ---- > The value is either a string or `#t'." > (or (assq-ref options key) default)) > > + (define (option-ref/many options key default) > + "Return value, or values, in alist OPTIONS using KEY, a symbol; or DEFAULT if not found. > + The value is either a string, a list or `#t'." > + (let loop ((rez #f) (opts options)) > + (if (null? opts) (or rez default) > + (if (eq? key (caar opts)) > + (cond > + ((pair? rez) (loop (cons (cdar opts) res) (cdr opts))) > + (rez (loop (list (cdar opts) rez) (cdr opts))) > + (else (loop (cdar opts) (cdr opts)))) > + (loop rez (cdr opts)))))) > + > ;;; getopt-long.scm ends here From unknown Tue Aug 19 12:51:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21698: accessing multiple flagged values with (ice-9 getopt-long) Resent-From: Matt Wette Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 24 Jun 2016 15:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21698 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Andy Wingo Cc: ludo@gnu.org, 21698@debbugs.gnu.org Received: via spool by 21698-submit@debbugs.gnu.org id=B21698.146678168122532 (code B ref 21698); Fri, 24 Jun 2016 15:22:02 +0000 Received: (at 21698) by debbugs.gnu.org; 24 Jun 2016 15:21:21 +0000 Received: from localhost ([127.0.0.1]:54465 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGSv3-0005rK-7J for submit@debbugs.gnu.org; Fri, 24 Jun 2016 11:21:21 -0400 Received: from omr-m010e.mx.aol.com ([204.29.186.10]:34481) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGSv1-0005r3-FT for 21698@debbugs.gnu.org; Fri, 24 Jun 2016 11:21:19 -0400 Received: from mtaout-mca02.mx.aol.com (mtaout-mca02.mx.aol.com [172.26.221.78]) by omr-m010e.mx.aol.com (Outbound Mail Relay) with ESMTP id D635B38001AE; Fri, 24 Jun 2016 11:21:13 -0400 (EDT) Received: from nautilus.championbroadband.com (nautilus.championbroadband.com [216.165.228.109]) by mtaout-mca02.mx.aol.com (MUA/Third Party Client Interface) with ESMTPA id E1BAB380000AD; Fri, 24 Jun 2016 11:21:12 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) From: Matt Wette In-Reply-To: <878txufxj9.fsf@pobox.com> Date: Fri, 24 Jun 2016 08:21:11 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <71713D65-96AD-4729-96AF-31828E3D3186@verizon.net> References: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> <878txufxj9.fsf@pobox.com> X-Mailer: Apple Mail (2.2104) x-aol-global-disposition: G x-aol-sid: 3039ac1add4e576d4fe83e37 X-AOL-IP: 216.165.228.109 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Thanks for the pointer. I can work with SRFI-37. I am OK w/ rejection = of the patch. =E2=80=94 Matt > On Jun 24, 2016, at 7:53 AM, Andy Wingo wrote: >=20 > Hi Matt, >=20 > 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. >=20 > https://www.gnu.org/software/guile/manual/html_node/SRFI_002d37.html >=20 > Ludovic, second opinions? >=20 > Andy >=20 > On Sat 17 Oct 2015 19:05, Matt Wette = writes: >=20 >> This is in reference to guile-2.0.11. >>=20 >> The (ice-9 getopt-long) module does not provide a process for >> accessing multiple command line arguments. >>=20 >> A patch for ice-9/getopt-long.scm is attached which adds the = procedure >> getopt-ref/many to access multiple argument values. >>=20 >> The following program and results illustrate the use of the current >> getopt-ref and the proposed getopt-ref/many: >>=20 >> mwette$ ./gotest.scm -f foo1 -b bar1 -f foo2 baz1 baz2 >>=20 >> program arguments: >>=20 >> ("./gotest.scm" "-f" "foo1" "-b" "bar1" "-f" "foo2" "baz1" "baz2") >>=20 >> getopt using option-ref: >>=20 >> foo: "foo2" >>=20 >> bar: "bar1" >>=20 >> getopt using option-ref/many: >>=20 >> foo: ("foo1" "foo2") >>=20 >> bar: "bar1" >>=20 >> where >>=20 >> mwette$ cat gotest.scm=20 >>=20 >> #!/opt/local/bin/guile >>=20 >> !# >>=20 >> (use-modules (ice-9 getopt-long)) >>=20 >> (define spec >>=20 >> '((foo (single-char #\f) (value #t)) >>=20 >> (bar (single-char #\b) (value #t)))) >>=20 >> (let* ((args (program-arguments)) >>=20 >> (opts (getopt-long args spec))) >>=20 >> (simple-format #t "program arguments:\n") >>=20 >> (simple-format #t "~S\n" args) >>=20 >> (simple-format #t "\ngetopt using option-ref:\n") >>=20 >> (simple-format #t "foo: ~S\n" (option-ref opts 'foo #f)) >>=20 >> (simple-format #t "bar: ~S\n" (option-ref opts 'bar #f)) >>=20 >> (simple-format #t "\ngetopt using option-ref/many:\n") >>=20 >> (simple-format #t "foo: ~S\n" (option-ref/many opts 'foo #f)) >>=20 >> (simple-format #t "bar: ~S\n" (option-ref/many opts 'bar #f)) >>=20 >> ) >>=20 >>=20 >>=20 >> *** getopt-long.scm-orig 2015-10-15 06:40:29.000000000 -0700 >> --- getopt-long.scm 2015-10-17 09:42:41.000000000 -0700 >> *************** >> *** 154,159 **** >> --- 154,173 ---- >> ;;; (option-ref (getopt-long ...) 'x-includes 42) =3D> = "/usr/include" >> ;;; (option-ref (getopt-long ...) 'not-a-key! 31) =3D> 31 >>=20 >> + ;;; (option-ref/many OPTIONS KEY DEFAULT) >> + ;;; Return value in alist OPTIONS using KEY, a symbol; or DEFAULT = if not >> + ;;; found. If multiple arg-options provided a list is returned. = The value >> + ;;; is either a string, a list or `#t'. >> + ;;; >> + ;;; For example, if the above was executed with multiple x-includes = flags, >> + ;;; then all will be returned in a list: >> + ;;; >> + ;;; (getopt-long '("my-prog" "-vk" "/tmp" "foo1" = "--x-includes=3D/usr/include" >> + ;;; "--x-includes=3D/opt/includd" "--" "-fred" = "foo2" "foo3") >> + ;;; grammar) >> + ;;; (option-ref/many (getopt-long ...) 'x-includes 42) >> + ;;; =3D> ("/usr/include" "/opt/include") >> +=20 >> ;;; Code: >>=20 >> (define-module (ice-9 getopt-long) >> *************** >> *** 162,168 **** >> #:use-module (ice-9 match) >> #:use-module (ice-9 regex) >> #:use-module (ice-9 optargs) >> ! #:export (getopt-long option-ref)) >>=20 >> (define %program-name (make-fluid "guile")) >> (define (program-name) >> --- 176,182 ---- >> #:use-module (ice-9 match) >> #:use-module (ice-9 regex) >> #:use-module (ice-9 optargs) >> ! #:export (getopt-long option-ref option-ref/many)) >>=20 >> (define %program-name (make-fluid "guile")) >> (define (program-name) >> *************** >> *** 368,371 **** >> --- 382,397 ---- >> The value is either a string or `#t'." >> (or (assq-ref options key) default)) >>=20 >> + (define (option-ref/many options key default) >> + "Return value, or values, in alist OPTIONS using KEY, a symbol; = or DEFAULT if not found. >> + The value is either a string, a list or `#t'." >> + (let loop ((rez #f) (opts options)) >> + (if (null? opts) (or rez default) >> + (if (eq? key (caar opts)) >> + (cond >> + ((pair? rez) (loop (cons (cdar opts) res) (cdr opts))) >> + (rez (loop (list (cdar opts) rez) (cdr opts))) >> + (else (loop (cdar opts) (cdr opts)))) >> + (loop rez (cdr opts)))))) >> +=20 >> ;;; getopt-long.scm ends here From unknown Tue Aug 19 12:51:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21698: accessing multiple flagged values with (ice-9 getopt-long) Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 24 Jun 2016 15:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21698 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Andy Wingo Cc: Matt Wette , 21698@debbugs.gnu.org Received: via spool by 21698-submit@debbugs.gnu.org id=B21698.146678225123943 (code B ref 21698); Fri, 24 Jun 2016 15:31:01 +0000 Received: (at 21698) by debbugs.gnu.org; 24 Jun 2016 15:30:51 +0000 Received: from localhost ([127.0.0.1]:54493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGT4F-0006E6-Ck for submit@debbugs.gnu.org; Fri, 24 Jun 2016 11:30:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32803) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGT4D-0006Dt-Fu for 21698@debbugs.gnu.org; Fri, 24 Jun 2016 11:30:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGT43-0007l4-Vf for 21698@debbugs.gnu.org; Fri, 24 Jun 2016 11:30:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGT43-0007kz-Oz; Fri, 24 Jun 2016 11:30:39 -0400 Received: from pluto.bordeaux.inria.fr ([193.50.110.57]:50078 helo=pluto) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bGT42-0008IK-RA; Fri, 24 Jun 2016 11:30:39 -0400 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> <878txufxj9.fsf@pobox.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 7 Messidor an 224 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-unknown-linux-gnu Date: Fri, 24 Jun 2016 17:30:36 +0200 In-Reply-To: <878txufxj9.fsf@pobox.com> (Andy Wingo's message of "Fri, 24 Jun 2016 16:53:46 +0200") Message-ID: <871t3m4nab.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.4 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.4 (------) Hello, Andy Wingo 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 =E2=80=9Cfreeze=E2=80=9D (ice-9 getop= t-long) and recommend SRFI-37. Ludo=E2=80=99. From unknown Tue Aug 19 12:51:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Matt Wette Subject: bug#21698: closed (Re: bug#21698: accessing multiple flagged values with (ice-9 getopt-long)) Message-ID: References: <87mvmacxvv.fsf@pobox.com> <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> X-Gnu-PR-Message: they-closed 21698 X-Gnu-PR-Package: guile Reply-To: 21698@debbugs.gnu.org Date: Fri, 24 Jun 2016 17:15:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1466788501-7725-1" This is a multi-part message in MIME format... ------------=_1466788501-7725-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 21698@debbugs.gnu.org. --=20 21698: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21698 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1466788501-7725-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 21698-done) by debbugs.gnu.org; 24 Jun 2016 17:14:38 +0000 Received: from localhost ([127.0.0.1]:54600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGUgg-0001zp-B4 for submit@debbugs.gnu.org; Fri, 24 Jun 2016 13:14:38 -0400 Received: from pb-sasl1.pobox.com ([64.147.108.66]:50684 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGUgf-0001zj-DH for 21698-done@debbugs.gnu.org; Fri, 24 Jun 2016 13:14:37 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 3266B1FD9B; Fri, 24 Jun 2016 13:14:36 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=OIn9EwF75dpL m+BRGLJjY/kqnkc=; b=sdxS9sg0Jadj1usxmSgXE/ciWklZfI5tu8WDsvVSRTbI rSzeeCu82hZT0vtwRQDbB9/cha2FzDT/lZAiUgKXZYUZHIEfSB8mVto32ow8HiJk vYi9ZL9aEPEzXnDK4vcU5j3K6h2DuwKdavUYrIhk1u6F/7ec/N9KSfKvwD+N28s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=FmQELq FeJ4jSXcLPQJbT2z6gVdft8RBWRaNwcO6x5ErWsvjSnejBh/sOthkIpGDCKJ6100 ByDwv1IIyvt8UYEFydf1escB7TimymABuyM/5xBqZb/tMl21vf8uM6J26gBg4db3 ucti9GSCDnpbRY9JN+nzIwRGbmo8h0f6lvvVA= Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 2AE131FD9A; Fri, 24 Jun 2016 13:14:36 -0400 (EDT) Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id 7339F1FD99; Fri, 24 Jun 2016 13:14:35 -0400 (EDT) From: Andy Wingo To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: bug#21698: accessing multiple flagged values with (ice-9 getopt-long) References: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> <878txufxj9.fsf@pobox.com> <871t3m4nab.fsf@gnu.org> Date: Fri, 24 Jun 2016 19:14:28 +0200 In-Reply-To: <871t3m4nab.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Fri, 24 Jun 2016 17:30:36 +0200") Message-ID: <87mvmacxvv.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pobox-Relay-ID: 1FFDC134-3A2F-11E6-B58A-C1836462E9F6-02397024!pb-sasl1.pobox.com X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: 21698-done Cc: 21698-done@debbugs.gnu.org, Matt Wette X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) On Fri 24 Jun 2016 17:30, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Andy Wingo 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 =E2=80=9Cfreeze=E2=80=9D (ice-9 get= opt-long) and > recommend SRFI-37. Okeydoke, closing. Thanks! Andy ------------=_1466788501-7725-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 17 Oct 2015 18:28:10 +0000 Received: from localhost ([127.0.0.1]:54605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZnWDB-0007Xb-AI for submit@debbugs.gnu.org; Sat, 17 Oct 2015 14:28:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54872) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZnUvz-0005di-81 for submit@debbugs.gnu.org; Sat, 17 Oct 2015 13:06:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnUvy-0008QO-1A for submit@debbugs.gnu.org; Sat, 17 Oct 2015 13:06:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUvx-0008QK-U4 for submit@debbugs.gnu.org; Sat, 17 Oct 2015 13:06:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUvx-0004Ig-16 for bug-guile@gnu.org; Sat, 17 Oct 2015 13:06:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnUvt-0008Ps-03 for bug-guile@gnu.org; Sat, 17 Oct 2015 13:06:16 -0400 Received: from vms173025pub.verizon.net ([206.46.173.25]:52141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUvs-0008Ph-Fq for bug-guile@gnu.org; Sat, 17 Oct 2015 13:06:12 -0400 Received: from [192.168.2.127] ([72.87.204.128]) by vms173025.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0NWD009H2JHVGUC0@vms173025.mailsrvcs.net> for bug-guile@gnu.org; Sat, 17 Oct 2015 12:05:56 -0500 (CDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=WpDWSorv c=1 sm=1 tr=0 a=Jf1g6iwM2K3MHzQE8uPn/Q==:117 a=o1OHuDzbAAAA:8 a=oR5dmqMzAAAA:8 a=5lJygRwiOn0A:10 a=2uEN-48ru5wOoboNUTwA:9 a=CjuIK1q_8ugA:10 a=hZV0AYy1jCtPVrdHdrEA:9 a=l57CAgH5AiQDqgUi:21 a=_W_S_7VecoQA:10 a=QpKWWIOaL3wNxZuwVIAA:9 a=boEB8yKzicCxs0FBlv8A:9 From: Matt Wette Content-type: multipart/alternative; boundary="Apple-Mail=_D42C07B0-EF94-4EA9-82E5-B3C94F8D9D47" Subject: accessing multiple flagged values with (ice-9 getopt-long) Date: Sat, 17 Oct 2015 10:05:53 -0700 Message-id: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> To: bug-guile@gnu.org MIME-version: 1.0 (Mac OS X Mail 8.2 \(2104\)) X-Mailer: Apple Mail (2.2104) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 17 Oct 2015 14:28:08 -0400 Cc: Matthew Wette X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) --Apple-Mail=_D42C07B0-EF94-4EA9-82E5-B3C94F8D9D47 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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=20 #!/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)) ) --Apple-Mail=_D42C07B0-EF94-4EA9-82E5-B3C94F8D9D47 Content-Type: multipart/mixed; boundary="Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB" --Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii 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))

  )

= --Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB Content-Disposition: attachment; filename=getopt-long.patch Content-Type: application/octet-stream; name="getopt-long.patch" Content-Transfer-Encoding: 7bit *** getopt-long.scm-orig 2015-10-15 06:40:29.000000000 -0700 --- getopt-long.scm 2015-10-17 09:42:41.000000000 -0700 *************** *** 154,159 **** --- 154,173 ---- ;;; (option-ref (getopt-long ...) 'x-includes 42) => "/usr/include" ;;; (option-ref (getopt-long ...) 'not-a-key! 31) => 31 + ;;; (option-ref/many OPTIONS KEY DEFAULT) + ;;; Return value in alist OPTIONS using KEY, a symbol; or DEFAULT if not + ;;; found. If multiple arg-options provided a list is returned. The value + ;;; is either a string, a list or `#t'. + ;;; + ;;; For example, if the above was executed with multiple x-includes flags, + ;;; then all will be returned in a list: + ;;; + ;;; (getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include" + ;;; "--x-includes=/opt/includd" "--" "-fred" "foo2" "foo3") + ;;; grammar) + ;;; (option-ref/many (getopt-long ...) 'x-includes 42) + ;;; => ("/usr/include" "/opt/include") + ;;; Code: (define-module (ice-9 getopt-long) *************** *** 162,168 **** #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 optargs) ! #:export (getopt-long option-ref)) (define %program-name (make-fluid "guile")) (define (program-name) --- 176,182 ---- #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 optargs) ! #:export (getopt-long option-ref option-ref/many)) (define %program-name (make-fluid "guile")) (define (program-name) *************** *** 368,371 **** --- 382,397 ---- The value is either a string or `#t'." (or (assq-ref options key) default)) + (define (option-ref/many options key default) + "Return value, or values, in alist OPTIONS using KEY, a symbol; or DEFAULT if not found. + The value is either a string, a list or `#t'." + (let loop ((rez #f) (opts options)) + (if (null? opts) (or rez default) + (if (eq? key (caar opts)) + (cond + ((pair? rez) (loop (cons (cdar opts) res) (cdr opts))) + (rez (loop (list (cdar opts) rez) (cdr opts))) + (else (loop (cdar opts) (cdr opts)))) + (loop rez (cdr opts)))))) + ;;; getopt-long.scm ends here --Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
--Apple-Mail=_D66DC0BE-2CBC-4D8A-AF46-69E69764E4BB-- --Apple-Mail=_D42C07B0-EF94-4EA9-82E5-B3C94F8D9D47-- ------------=_1466788501-7725-1-- From unknown Tue Aug 19 12:51:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21698: accessing multiple flagged values with (ice-9 getopt-long) Resent-From: Matt Wette Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 25 Jun 2016 00:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21698 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Andy Wingo , 21698@debbugs.gnu.org Received: via spool by 21698-submit@debbugs.gnu.org id=B21698.146681353521206 (code B ref 21698); Sat, 25 Jun 2016 00:13:02 +0000 Received: (at 21698) by debbugs.gnu.org; 25 Jun 2016 00:12:15 +0000 Received: from localhost ([127.0.0.1]:54773 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGbCp-0005Vx-KC for submit@debbugs.gnu.org; Fri, 24 Jun 2016 20:12:15 -0400 Received: from omr-m009e.mx.aol.com ([204.29.186.8]:53334) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGbCn-0005Vj-7i for 21698@debbugs.gnu.org; Fri, 24 Jun 2016 20:12:14 -0400 Received: from mtaout-aag02.mx.aol.com (mtaout-aag02.mx.aol.com [172.26.126.78]) by omr-m009e.mx.aol.com (Outbound Mail Relay) with ESMTP id EC4BB3800087; Fri, 24 Jun 2016 20:12:07 -0400 (EDT) Received: from nautilus.championbroadband.com (nautilus.championbroadband.com [216.165.228.109]) by mtaout-aag02.mx.aol.com (MUA/Third Party Client Interface) with ESMTPA id 67F083800008E; Fri, 24 Jun 2016 20:12:07 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) From: Matt Wette In-Reply-To: <871t3m4nab.fsf@gnu.org> Date: Fri, 24 Jun 2016 17:12:06 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <34B3FA9E-EDD5-492B-8473-CEAF770E1241@verizon.net> References: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> <878txufxj9.fsf@pobox.com> <871t3m4nab.fsf@gnu.org> X-Mailer: Apple Mail (2.2104) x-aol-global-disposition: G x-aol-sid: 3039ac1a7e4e576dcc5708a4 X-AOL-IP: 216.165.228.109 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) > On Jun 24, 2016, at 8:30 AM, Ludovic Court=C3=A8s = wrote: >=20 > Hello, >=20 > Andy Wingo skribis: >=20 >> 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. >>=20 >> https://www.gnu.org/software/guile/manual/html_node/SRFI_002d37.html >>=20 >> Ludovic, second opinions? >=20 > Seconded. I think we should probably =E2=80=9Cfreeze=E2=80=9D (ice-9 = getopt-long) and > recommend SRFI-37. Agree. Could you at the least add a reference to SRFI-37 in the section = on (ice-9 getopt-long), in case you don=E2=80=99t go further =E2=80=94 = e.g., replace it? Matt From unknown Tue Aug 19 12:51:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21698: accessing multiple flagged values with (ice-9 getopt-long) Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 25 Jun 2016 08:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21698 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Matt Wette Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 21698@debbugs.gnu.org Received: via spool by 21698-submit@debbugs.gnu.org id=B21698.14668420348934 (code B ref 21698); Sat, 25 Jun 2016 08:08:01 +0000 Received: (at 21698) by debbugs.gnu.org; 25 Jun 2016 08:07:14 +0000 Received: from localhost ([127.0.0.1]:54878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGicU-0002K2-Ch for submit@debbugs.gnu.org; Sat, 25 Jun 2016 04:07:14 -0400 Received: from pb-sasl2.pobox.com ([64.147.108.67]:64158 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGicS-0002Ju-7w for 21698@debbugs.gnu.org; Sat, 25 Jun 2016 04:07:12 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id B4BBE1C057; Sat, 25 Jun 2016 04:07:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=ggv6kbUxWY4m vbno5bU6eySOy2Q=; b=WL2fofuWmE/heeVjE5eC7N+AEu5Pcs0oWlmJnzvGmrlt BtOcYygcT6wsZ9vnoqAkg4XMDSoSJXVrWgK7rORwjeVlcZNfx/W37dCkgqgV69+5 SzXrfB7QolZJLg4ILQp/EFyllZ/IH5+TEgCLVxfwZcGelYEVdafDnlggU5mTaAM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=uY3VZ0 trD3DY2EuXSDXiUxUAO3C5WirrIMgyMQnjHbf5+CI/4GnevTHwR/ANoJjQXmAAOd QLT757qx+4C+n4esyYABC7SsfkDhnLHiMSW5lEMk7DnmaWdHoJ/9BtrnboMS5/xb bQ8AO3GWH0v3TvYp+fm98SXaR2/glumGatHfY= Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 9FB621C055; Sat, 25 Jun 2016 04:07:11 -0400 (EDT) Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id B7CE51C054; Sat, 25 Jun 2016 04:07:10 -0400 (EDT) From: Andy Wingo References: <0B36F95D-923F-465F-A7CA-52C98F58AFC7@verizon.net> <878txufxj9.fsf@pobox.com> <871t3m4nab.fsf@gnu.org> <34B3FA9E-EDD5-492B-8473-CEAF770E1241@verizon.net> Date: Sat, 25 Jun 2016 10:07:01 +0200 In-Reply-To: <34B3FA9E-EDD5-492B-8473-CEAF770E1241@verizon.net> (Matt Wette's message of "Fri, 24 Jun 2016 17:12:06 -0700") Message-ID: <8737o1d74q.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pobox-Relay-ID: D182A9F2-3AAB-11E6-BF6F-28A6F1301B6D-02397024!pb-sasl2.pobox.com X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) On Sat 25 Jun 2016 02:12, Matt Wette writes: > Could you at the least add a reference to SRFI-37 in the section on > (ice-9 getopt-long), in case you don=E2=80=99t go further =E2=80=94 e.g.,= replace it? Done (in master, will backport later). Andy