From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id cC2dAS1uw2KYFQAAbAwnHQ (envelope-from ) for ; Tue, 05 Jul 2022 00:48:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4AOTAS1uw2IKqAAA9RJhRA (envelope-from ) for ; Tue, 05 Jul 2022 00:48:13 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 95D4F271B3 for ; Tue, 5 Jul 2022 00:48:12 +0200 (CEST) Received: from localhost ([::1]:44970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8UrS-0005OF-3l for larch@yhetil.org; Mon, 04 Jul 2022 18:48:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Ur5-0005Nm-C6 for guix-devel@gnu.org; Mon, 04 Jul 2022 18:47:47 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:33427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o8Ur3-0006za-Ha; Mon, 04 Jul 2022 18:47:47 -0400 Received: by mail-wr1-x436.google.com with SMTP id h17so1970863wrx.0; Mon, 04 Jul 2022 15:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=OMFAw1seVh/oxVCGSH6EwvuhmSdJI/z4Vc8oekFrERc=; b=o2Z6ZWyYroKG4XyzpJ32ya/ltMawiDofVcCHizg5CP5ilRsGn64FX5SVIbZDwz/JtJ tVHLRLgy58u2xL5+C03VJ0hBSvUXGiC+V+EkPMSbaUkSXHkqPBX8IhzmBWVqYl+O2DQd l/b1wGrdnZSa3MOfjgcbFCuLYl3qI+xX8jnpkeGdhS1VXSS2dPFz9kjocnAdCr8x3/lp kHRjsO3D0HLDthgE7KA/+DfczkthxOx/yWvnCZxvlGS5eOYvLC5T6S7KmwXsFgGHnh/2 mExOBzomoh9qLOD5IasO4ZxKjO2JK8txVJiAixqyRRU21V/YZaXBRPp7gWKLXpuT3VOi iBJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=OMFAw1seVh/oxVCGSH6EwvuhmSdJI/z4Vc8oekFrERc=; b=tFxPRRzb03KGpgWOiTOvazyEo5wl+bYf1K77G0wiHnCl60lD7h2PpvwYxqZx2OkCq8 o6KX36MP6iOyslScpXJIFuEyeH/vKWk4kyk7VWCsg3v/EeVJXdMMuP/by6zpzryGWy7S uwZsQl6u9gSkGZ5Ay7eXsidA5iUMsrm8HyhA8NRdCeeXjDte5JVjM9mcKsbpSM7031vS U3iZ0RhYbPeoLM+06Vhx+CuwqfQi9RIRwHPNthLcrdwubANPtQjBaWqDZsy9qz58qn5n wYVp6C78uMbAU2yJTevM1CjK+/KLSgtp7fQY3YKG2YmPIv9rWft3yl+5OQMXTguPpann wN7w== X-Gm-Message-State: AJIora/8zZnUxlpa4Mrc81cK+o0/ngr9LZnJ4Sy4YgFJxTw+Sa2gWJVB N97/THKL0nEPhCfoz81AlREFSQ7Q1p/dJw== X-Google-Smtp-Source: AGRyM1sO0KEje+iDN2U5Khew/0tao5VNle6EZGKV1bU0ehzfrJWZB94H2MV//VFKJaQkggrzRwe08A== X-Received: by 2002:a05:6000:15c3:b0:21b:abc6:744a with SMTP id y3-20020a05600015c300b0021babc6744amr28273094wry.478.1656974860259; Mon, 04 Jul 2022 15:47:40 -0700 (PDT) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id m32-20020a05600c3b2000b0039744bd664esm17648313wms.13.2022.07.04.15.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 15:47:39 -0700 (PDT) From: zimoun To: Tobias Geerinckx-Rice , guix-devel@gnu.org, jgart , Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: Guix Devel Subject: Re: repl macro (metacommand?) for guix CLI (sub)commands In-Reply-To: References: <20220703131112.GB5967@gac> <87mtdpau7y.fsf@gnu.org> <20220704132159.GC3017@gac> Date: Tue, 05 Jul 2022 00:47:07 +0200 Message-ID: <86tu7wxzpw.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1656974892; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=OMFAw1seVh/oxVCGSH6EwvuhmSdJI/z4Vc8oekFrERc=; b=Bl2oVVgvEmcq0NsaLtxpv+sXXs7wQ9xWjodyXNUF2XIpHZADer4rBzHHtBBZp80DgwyJ6h GOJcbxcRD1C3glg6XUpg4Ui6aJ0W26z1fsaYIDg7V3Fus/weROz09Dfzo4JKTih0f6tAYN H0fBjA8PXt9yEneJ1Ddq0KstiozimPNWiK8SDbzAwWitEm0GNyrUBQrbovFTSjp8U5AI6w UvCN/yCHXJpprxSI3vabKGeRRfuEjD5El3K8QfFakXTtopnHz405E3Jh3DqZvDmfHg8Jdr SixudFfmoabYA1RUJm77MpU2GKKUbM4Oi9W+I+D6Se4HP/2K5VGV1bXCqhAQaQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656974892; a=rsa-sha256; cv=none; b=iMt9PLd7QsefA7i4RIPpduSWoMv67xvoc3YiojCSihxHg6pkckPOfxPkd1Py23HLjRuh84 tPv867PRH5IzgnWybVgWNVWiZqBAUVdaI2Z0DMvymz7ky3N+q/+2wUVataefnQZZ5+LW8/ 7foXFFAGo/HtC8Vna/HI0ZlLn4i1mK64ahFy3OBxtsibWJlCpzILxoaLShxzB7Zn1ociNH i5uQw+WZwCahcrgGwMK5NFfqa9qpyTmDjiFXg2fwC0fNSPaxQU2LI+2pEyet/t69H15xws GIOdWtxkJAkPxDxF50pu1sm5h5FF/Mg5A2g34nHlaQuIbHz/gYznLQU8OcSn2g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=o2Z6ZWyY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.75 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=o2Z6ZWyY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 95D4F271B3 X-Spam-Score: -5.75 X-Migadu-Scanner: scn0.migadu.com X-TUID: IgIWtBpsEHCz Hi, >>This is because each of those "CLI calls" end up running `(exit 0)` >>at the end in some form or another. Quote: What do guixers think of having a repl macro that allows you to run commands like if you were using the CLI? therefore using (guix-package "-s" "non-existent") =C2=ABallows you to run commands like if you were using the CLI=C2=BB. ;-) > Should they? Is this an accepted pattern in the functional style to > which Guix tries to adhere? > > (I don't know! It just caught me by surprise.) For instance it reads, --8<---------------cut here---------------start------------->8--- (define %options ;; Specification of the command-line options. (cons* (option '(#\h "help") #f #f (lambda args (show-help) (exit 0))) --8<---------------cut here---------------end--------------->8--- or elsewhere for another instance, --8<---------------cut here---------------start------------->8--- (define (handle-argument arg result arg-handler) ;; Process non-option argument ARG by calling back ARG-HANDLER. (if arg-handler (arg-handler arg result) (leave (G_ "~A: extraneous argument~%") arg))) --8<---------------cut here---------------end--------------->8--- where =E2=80=99leave=E2=80=99 reads, --8<---------------cut here---------------start------------->8--- (define-syntax-rule (leave args ...) "Emit an error message and exit." (begin (report-error args ...) (exit 1))) --8<---------------cut here---------------end--------------->8--- It appears to me expected that the imperative CLI called from shell returns meaningful code that the shell caller can use. I do not know what is expected for working at the REPL. The direct use =E2=80=99define-command=E2=80=99 is a quick workaround. Other said, the ru= n of scheme@(guix-user)> (guix-package "-s" "hello") instead of the CLI =E2=80=9Cguix package -s hello=E2=80=9D is just to expos= e an entry point for the Scheme API. Because the procedure =E2=80=99guix-package=E2= =80=99 is to somehow make a compatible layer between the functional style with the imperative shell world =E2=80=93 hence all the =E2=80=99leave=E2=80=99 or = =E2=80=99warning=E2=80=99 glue code. Except some corner cases, the general idea, from my understanding, is to have all the impure/imperative code under guix/scripts/. Although it is sadly more than often not the case; give a look at (gnu packages) for instance. Anyway. Well, the functional style at the REPL would to directly use for example =E2=80=99find-packages-by-description=E2=80=99 or the like; although this p= rocedure is not exposed by the API. All that said, maybe it could be nice to extend the current meta-commands of the REPL. What would be the need between the current CLI and the current Scheme API? Maybe all the =E2=80=99leave=E2=80=99 and =E2=80=99exit=E2=80=99 could be w= rapped using an hypothetical =E2=80=99maybe-exit=E2=80=99 catching if it is called from REPL or not. Is it possible to detect if an interactive call? I was thinking to add a global parameter in =E2=80=99(guix scripts repl) and then this new =E2=80=99maybe-exit=E2=80=99 could check it; but I guess Guile provides a b= etter mechanism for checking interactiveness. Cheers, simon