guile-user
[Top][All Lists]
Advanced

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

Re: guile-config: How do I use a <codex>?


From: sirgazil
Subject: Re: guile-config: How do I use a <codex>?
Date: Wed, 15 Jan 2020 18:18:03 -0500
User-agent: Zoho Mail

 ---- On Wed, 15 Jan 2020 16:08:51 -0500 Alex Sassmannshausen <address@hidden> 
wrote ----
 > Hi!
 > 
 > sirgazil <address@hidden> writes:
 > 
 > > […]
 > >
 > > I'm trying out guile-config to declare the CLI of the program using a
 > > <configuration> record
 > > (https://gitlab.com/sirgazil/guile-lab/blob/master/scripts/cli/sprinklers#L96)
 > 
 > You can actually make use of config's inheritance here, because
 > oscillate is shared by all subcommands.  You can specify oscillate in
 > the top-level command and then use the (wanted …) property of each
 > subcommand <configuration> object to say you would like to inherit
 > oscillate from its parent.  I think this one is documented correctly in
 > the manual! :-)

Yeah, I thought about it, but running "sprinklers --help" displayed the 
"--oscillate" flag as an option of the "sprinklers" command too, which is 
actually not what I wanted...


 > > […]
 > >
 > > So, for example, using the <codex> record, how would I map the following 
 > > command
 > >
 > >   $ sprinklers start A5
 > >
 > > to a Guile procedure like
 > >
 > >   (define (sprinkler-start id) ...)
 > 
 > I think this is one place for the documentation of config let you down!
 > 
 > The procedure you want to use here is (full-command <codex>). This will
 > give you a list of string elements, each being a "breadcrumb" down the
 > trail of subcommands.

Oh, right, the "full-command" procedure is not documented in the manual.


 > This is how I tend to use it:
 > 
 > (match (full-command options)  ; options is a <codex>
 >   ((_ "start")
 >    (sprinkler-start (option-ref options '(id))))  ; id is arg, not key
 >    …)
 
Thank you Alex, that solves, my problem :)







reply via email to

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