[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: guile-config: How do I use a <codex>?
From: |
Alex Sassmannshausen |
Subject: |
Re: guile-config: How do I use a <codex>? |
Date: |
Wed, 15 Jan 2020 22:08:51 +0100 |
User-agent: |
mu4e 1.2.0; emacs 26.3 |
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! :-)
> […]
>
> 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.
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
…)
Hth,
Alex