unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
To: guile-user@gnu.org
Subject: Re: guile-config: How do I use a <codex>?
Date: Wed, 15 Jan 2020 22:08:51 +0100	[thread overview]
Message-ID: <87ftgg2zrw.fsf@gmail.com> (raw)
In-Reply-To: <16faaa06bfd.db91abab66860.6304475598181299647@zoho.com>

Hi!

sirgazil <sirgazil@zoho.com> 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



  reply	other threads:[~2020-01-15 21:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 19:13 guile-config: How do I use a <codex>? sirgazil
2020-01-15 21:08 ` Alex Sassmannshausen [this message]
2020-01-15 23:18   ` sirgazil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ftgg2zrw.fsf@gmail.com \
    --to=alex.sassmannshausen@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).