From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 10227439BB; Thu, 25 Jan 2024 07:31:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 990A64029B; Thu, 25 Jan 2024 07:31:24 +0100 (CET) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by mails.dpdk.org (Postfix) with ESMTP id 6E3504027B for ; Thu, 25 Jan 2024 07:31:22 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4TL9v45Hhmz1vsZD; Thu, 25 Jan 2024 14:30:56 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 2E05D1A0176; Thu, 25 Jan 2024 14:31:04 +0800 (CST) Received: from [10.67.121.161] (10.67.121.161) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 25 Jan 2024 14:31:03 +0800 Subject: Re: [24.03 RFC] argparse: add argparse library To: Stephen Hemminger CC: , , References: <20231121122651.7078-1-fengchengwen@huawei.com> <20240124075457.0a52c8b1@hermes.local> From: fengchengwen Message-ID: <706f7098-12b3-7365-9d50-d86ee56d4d7a@huawei.com> Date: Thu, 25 Jan 2024 14:31:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20240124075457.0a52c8b1@hermes.local> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.161] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500024.china.huawei.com (7.185.36.10) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Stephen, On 2024/1/24 23:54, Stephen Hemminger wrote: > On Tue, 21 Nov 2023 12:26:51 +0000 > Chengwen Feng wrote: > >> Introduce argparse library (which was inspired by the thread [1]), >> compared with getopt, the argparse has following advantages: >> 1) Set the help information when defining parameters. >> 2) Support positional parameters. >> >> The parameters parsing according following: >> 1) positional: use callback to parse (passed the long-name as the key >> for callback). >> 2) optional: >> In addition to callback to parse, but also support: >> 2.1) no-val: support set default value to saver. >> 2.2) has-val: support set value to saver, the value must be conform >> RTE_ARGPARSE_ARG_VAL_xxx. >> 2.3) opt-val: if current without value then treat as no-val, else could >> treat as has-val. > > How compatiable is this with Python or other implementations of argparse > in C? This library is a subset of Python argparse, and it don't support some advanced features, such as: subcommand, exclusive group. We could extend it to support if needed. As for other implementation of argparse in C, I found a interesting site [1], this library supports all features except the compact/order/wchar. [1] https://attractivechaos.wordpress.com/2018/08/31/a-survey-of-argument-parsing-libraries-in-c-c/ Thanks > > . >