[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
guile-config: How do I use a <codex>?
From: |
sirgazil |
Subject: |
guile-config: How do I use a <codex>? |
Date: |
Wed, 15 Jan 2020 14:13:57 -0500 |
User-agent: |
Zoho Mail |
I designed the following CLI for an example program that pretends to control
irrigation sprinklers.
$ sprinklers
Display some information about the sprinklers in the farm.
$ sprinklers start-all
All sprinklers started.
$ sprinklers stop-all
All sprinklers stopped.
$ sprinklers start A5
Sprinkler A5 started.
$ sprinklers stop A5
Sprinkler A5 stopped.
All subcommands accept a --oscillate flag. For example:
$ sprinklers start --oscillate A5
Sprinkler A5 started in oscillation mode.
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)
and I have defined a "dispatcher" procedure that is supposed to run some Guile
procedure depending on the command entered by the user
(https://gitlab.com/sirgazil/guile-lab/blob/master/scripts/cli/sprinklers#L165).
But I don't understand how to use the <codex> record for that purpose (I'm
currently matching command patterns against the result of (command-line)
instead to make the example program work).
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) ...)
Thanks,
---
https://sirgazil.bitbucket.io/
- guile-config: How do I use a <codex>?,
sirgazil <=