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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18406 invoked from network); 31 Jul 2021 15:57:18 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 31 Jul 2021 15:57:18 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 58A309C9E4; Sun, 1 Aug 2021 01:57:15 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id EBE079C9B2; Sun, 1 Aug 2021 01:56:57 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uGffPsBM"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 4B86A9C9B2; Sun, 1 Aug 2021 01:56:54 +1000 (AEST) Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) by minnie.tuhs.org (Postfix) with ESMTPS id 2A27D9C9AF for ; Sun, 1 Aug 2021 01:56:53 +1000 (AEST) Received: by mail-vk1-f176.google.com with SMTP id i13so2687890vkd.12 for ; Sat, 31 Jul 2021 08:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=cxyYdI/nudWqiWX6JjqBgeqrDgd4BJW2Enj9V/cSOOU=; b=uGffPsBMzw8WHAbnPRlVAj6jna4POaiTLW5uRfgg8xjVYSr/ZlHT2MpgTBtq3DFASv 7EcUAabfDggLFXBfYviEnX8PE9Goqw+Eh3dvR0B0tptMwzMGVSWpGMF0Z5v+lXPUl9AB NWszwVQ4lly59hurTdAsCW4BaWvvE4t+HjxkelYaIICHqms5k3e3JdCf/klzv1nGG/aL BFfSk2CnA+2K/EmdnXSxlw5Oxu+v/4xnwPdJHBwmGdddQfHckB10/p6J71Msc4peaWwD aZ1ZAkgsCFeV5cjnUFeLKmDHIhY2Xfhu+dr/tsVY0ezoKquxLSJzpPMDclSI4fUSEru6 d3lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=cxyYdI/nudWqiWX6JjqBgeqrDgd4BJW2Enj9V/cSOOU=; b=cXCpr8uqIr3wTawi5P09fvkgMpf4twhKOX6XyTSl/eTFrIL8JJ3aUj9xTHA6boLbc2 ImZJUJJ7qUr9GUCzuaJTwRFZjCerzriO0bhv56mUNmF100NLolbyqJ2Sz7CvTliIztGy mDD2QGqspBLETnGB8He9a2J7UR+tVy09yZqfLQqIuUwMyKvv9yjmXjWAalgStHGtP6Fn H7I1+bB1BL/ihR9aGzAX7zf/EXj9dU/Enc1xH2/n9ONo5AMHPfSejwbar2VvdgrjYEkb r8H7VnFLrRQvm1dOxoouh1V1IEH++rq2aMVytb6I/okLGXs3d1l7lGvohRrfNh4/NCEn cpfQ== X-Gm-Message-State: AOAM533pzVXuzrIaW2JXq2+UKZkzZOVD/SAR1buJgYaUUEwwLy5LhqXy lEkj92hdks39BstwGRkNit8ldu+Zq6rxZzP7Z9MSN4HA X-Google-Smtp-Source: ABdhPJzNZsHHt+JLczM8Td6aaphCH32aszSGHBEQjMGYmQo0uqTFdgYQAsrYT2+pR6YXAHZCzZrCx/uGvuTvvAiamCo= X-Received: by 2002:a1f:5381:: with SMTP id h123mr5118960vkb.25.1627747012266; Sat, 31 Jul 2021 08:56:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:739a:0:0:0:0:0 with HTTP; Sat, 31 Jul 2021 08:56:51 -0700 (PDT) In-Reply-To: <20210731142533.69caf929@moon> References: <20210731142533.69caf929@moon> From: Paul Winalski Date: Sat, 31 Jul 2021 11:56:51 -0400 Message-ID: To: Michael Siegel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [TUHS] Systematic approach to command-line interfaces 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: tuhs@minnie.tuhs.org Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" On 7/31/21, Michael Siegel wrote: > > While doing that, I learned that there is a better way to approach > this problem =E2=80=93 beyond using getopt(s) (which never really made se= nse to > me) and having to write case statements in loops every time: Define a > grammar, let a pre-built parser do the work, and have the parser > provide the results to the program. This method for handling command lines dates back at least to the 1970s. The COMND JSYS (system call) in TOPS-20 operated this way, as does the DCL command line interface in OpenVMS. As you pointed out it can greatly simplify the code in the application. It also permits command completion. If the command has a long-winded option, such as -supercalifragilisticexpialidocious, I can type -super then hit the TAB key and as long as there is only one option that starts with -super the parser will fill in the rest of the long keyword. It also means that you can provide interactive help. At any point the user can type a question mark and the command interpreter will say what syntactic element is expected next. The TOPS-20 COMND JSYS implemented both of these features, and I think that command completion was eventually added to the VMS command interpreter, too. This method of command line parsing also enforces a degree of uniformity of syntax between the command lines of the various utilities and applications. -Paul W.