From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22366 invoked from network); 1 Aug 2021 21:31:09 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 1 Aug 2021 21:31:09 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id BDFD59CA92; Mon, 2 Aug 2021 07:31:05 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 91F379CA63; Mon, 2 Aug 2021 07:30:35 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=ccil-org.20150623.gappssmtp.com header.i=@ccil-org.20150623.gappssmtp.com header.b="iTgZZ0Z3"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 165359CA63; Mon, 2 Aug 2021 07:30:33 +1000 (AEST) Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by minnie.tuhs.org (Postfix) with ESMTPS id D47859CA60 for ; Mon, 2 Aug 2021 07:30:31 +1000 (AEST) Received: by mail-qt1-f177.google.com with SMTP id a19so10456908qtx.1 for ; Sun, 01 Aug 2021 14:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccil-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rlol7SeHGpCFGJFdXKXi3/OEQm337sdu9hz6FNUDPWk=; b=iTgZZ0Z3/Mm9KW/t3RpVjDyWTqc10n2GUq1nsx6DzB9Leaz3i3QeAZNkgVnqTV+vPG 56/Bqm4BaBR998stsGaYc6HXZYmr4VyHIJGi+ZdZS1wQ6RSA3250rsFEyDwXSqpQVfB3 9Wg2Zt5W9rDxqKjGVCBCyZea+DaNTvYgUXblO961kMX6tgTcVNJpkiRUNe8Or32I95eH ePIHWZJYFOaVM+dZpXHTkurLMLxwzimyOM0pVuSh7Ri2Ll1x1X78EHWyk/8c2yD7vqIA D6eB0s5JTCnvLws1Q6kChrhWtH1Nv1KBsZS0+c51wLakgEyKadrFXQAiqtiPdHKkmCrY fudA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rlol7SeHGpCFGJFdXKXi3/OEQm337sdu9hz6FNUDPWk=; b=Xa+IxUBnZxzbizc0K1JD0As5gCxZqIYagzyGainI0/aij84tQOzwwU03Db2CmNeVE5 PMl7Om5/cFlmZZgFUdvqWy7Td7jeVaJabySlAessQSTMGxd02J2Y2p2AYIl+qW1k7LsG zDvP1fD+z/23ytLreVF/D8spDSFymfVsgyGNv9CqyX9D5HaFQDApMvjCrOGEf5q8sNeg 5dmKGcqkpXz8xbhEeyyt6OgDYQYzjvgStTMscTdyUATB0BXCgEguLQAhyXo/WIPg8ea8 VnDtPteoEO4pMN8Kh8ZCiI/6QkFSr3ngwrMkHu8xgsyu4NU+BHPtzYw47XXipKeSYdDU usfw== X-Gm-Message-State: AOAM533r6fMFyfUWb2aMk76BHTgh2vBhGuTsH9QgjCCIge3mkke+bXyE IiDgftvDcI3L6E+Oh099zD/aIhSIrtbdhp/KxiPhDQ== X-Google-Smtp-Source: ABdhPJxydBYPEKG84aD0Vk2gVLr8tIFVjvKGmeL8/rz/0ahgcsyHSyPeVVUBT5Ph5kHkGqRZlL0Zw+g91Z8T38WAg4U= X-Received: by 2002:ac8:4253:: with SMTP id r19mr2449929qtm.45.1627853430892; Sun, 01 Aug 2021 14:30:30 -0700 (PDT) MIME-Version: 1.0 References: <202108011948.171JmAcK001895@freefriends.org> In-Reply-To: <202108011948.171JmAcK001895@freefriends.org> From: John Cowan Date: Sun, 1 Aug 2021 17:30:19 -0400 Message-ID: To: arnold@skeeve.com Content-Type: multipart/alternative; boundary="0000000000007ebe1d05c8862916" Subject: Re: [TUHS] Systematic approach to command-line interfaces [ meta issues ] X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Eunuchs Hysterical Society , M Douglas McIlroy Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --0000000000007ebe1d05c8862916 Content-Type: text/plain; charset="UTF-8" On Sun, Aug 1, 2021 at 3:48 PM wrote: > I happen to like the getopt_long interface designed by the GNU > project. It's easy to learn, setup and use. Once it's in place > it's set and forget. > I agree, and what is more, I say, it is a grammar already, if a simple one. You declare what you accept and what's to be done, making it a DSL expressed as an array of structs. The only thing it lacks is that old getopt is a bag on the side rather than being integrated: struct option should have an additional member "char short_option", where '\0' means "no short option". Given that feature and three per-program values "progname" (argv[0] by default), "version", and "usage_string", the --version and --help options can be processed inside getopt itself. I especially like that you pass per-option pointers saying where to put the value, so no case statement required, just create some global or local variables and pass in their addresses. Automatic support for "--nofoo" given "--foo" would be good as well. --0000000000007ebe1d05c8862916 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sun, Aug 1, 20= 21 at 3:48 PM <arnold@skeeve.com> wrote:
I happen to like the getopt_long interface designed by the GN= U
project. It's easy to learn, setup and use. Once it's in place
it's set and forget.

--0000000000007ebe1d05c8862916--