From: Xinglu Chen <public@yoctocell.xyz>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: Best practices for writing services
Date: Fri, 23 Apr 2021 08:04:22 +0200 [thread overview]
Message-ID: <877dkt5yft.fsf@yoctocell.xyz> (raw)
In-Reply-To: <87tunx1uim.fsf@gmail.com>
Hi,
On Fri, Apr 23 2021, Maxim Cournoyer wrote:
>> But the problem here is that it doesn’t force the user to configure the
>> field. In a Git config for example, the user should be forced to set
>> ‘user.name’ and ‘user.email’, otherwise they can’t commit anything. You
>> will just have to set the default value to ‘disabled’, like this:
>>
>> #+begin_src scheme
>> (define (serialize-string field-name val) ...)
>> (define-maybe string)
>> (define-configuration test-config
>> (config
>> (maybe-string ’disabled))
>> "docs"")
>> #+end_src
>
> Ah, thanks for explaining, now I understand your point well.
>
> I've just tried something:
>
> --8<---------------cut here---------------start------------->8---
> (define-configuration test-config
> (name (string #f) "Your name"))
> scheme@(guile-user)> (test-config)
> ice-9/boot-9.scm:1669:16: In procedure raise-exception:
> ERROR:
> 1. &message: "Invalid value for field name: #f"
> 2. &configuration-error
> --8<---------------cut here---------------end--------------->8---
>
> So you could choose an invalid default value, which would force the user
> to specify it (else they'd get the not so obvious error message above).
> It should be improved too! I'll see if I can do something.
That would be a workaround for now. Thank you!
next prev parent reply other threads:[~2021-04-23 6:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-18 15:23 Best practices for writing services Xinglu Chen
2021-03-19 16:12 ` Joshua Branson
2021-03-19 17:01 ` Xinglu Chen
2021-04-21 3:54 ` Maxim Cournoyer
2021-04-21 10:45 ` Xinglu Chen
2021-04-21 18:05 ` Maxim Cournoyer
2021-04-22 7:27 ` Xinglu Chen
2021-04-23 4:42 ` Maxim Cournoyer
2021-04-23 6:04 ` Xinglu Chen [this message]
2021-04-21 22:10 ` raingloom
2021-04-22 7:19 ` Xinglu Chen
2021-04-26 20:29 ` raingloom
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://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877dkt5yft.fsf@yoctocell.xyz \
--to=public@yoctocell.xyz \
--cc=guix-devel@gnu.org \
--cc=maxim.cournoyer@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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).