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 DDC8B4318E; Tue, 17 Oct 2023 19:08:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6CDD402DE; Tue, 17 Oct 2023 19:08:41 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id AD81A402B3 for ; Tue, 17 Oct 2023 19:08:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697562519; x=1729098519; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=2ufPqYCCmCKDq5eJrkWanycdeznMn/y283LrcbBZ/88=; b=MqoEuRuwYf4SKmGyZ1RkKfAOM2fiQcPA1yMcSeoJ44ZyfcaITWY03phb g3NZcx1fM4umnE6T7TkmqWo+EUaJdyG/cSc3HNX4O7AE5GMmixcqEN5Xl UouRK+Gldjpzi0DDDrqrOR1hGYi4f2e7iIkrZzPkbaQsSZmDLH7okGWm9 JPSLl10wpnBlJ+t3ABlgXfbu6xGWXgr/oMSo/MNgSLW/989wTZ/dCBHOj 0mnr6ZKvZ3kr9UND1gbekwsJtLHtGv93I3fGvA83GSz19YVMcg2seU17t cNUPnyHHe3kUb92/MLkWL9IdO9yRRhr8JMyVGIg0a2befeAPVAdP+0biN A==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="376202497" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="376202497" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 10:08:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="846899922" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="846899922" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by FMSMGA003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 17 Oct 2023 10:08:37 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 17 Oct 2023 10:08:37 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 17 Oct 2023 10:08:36 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Tue, 17 Oct 2023 10:08:36 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.101) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Tue, 17 Oct 2023 10:08:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KPQElKljiWZg1XDNcQImWbcO8W5IMbWEBHk+yCUl2CYUwIqbWNqwe3B04FRjYr3BgeB/U+r8kBHyBuJ82D9j036vhKE3qbuqNHQniPEB2E1CnqZBoGb2K1bYdcxpJfSd+H1W0JI2xb4JFudf8NxaQGUVFwR8mn3/NhN/Xj49VASKTTBo1g2Lx8/oZsyUZBhxIPU5knSwqLnGcyOCyXDPHNBuepaly0uX1ryb5VbnbBwqRnnDRdn1HmbXSIeggfwpqNBfjG8pbGGUJ2b50b156Dr/PAMdkiqFeHZUFYrh5oGZdlgoAgUGYruk87bLh5jqN0Xf6VsWYhT4InFNfO3/UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T2TkVE39Bz9MBtFVaqRty7KwF0904E5rAUbhfclPKNw=; b=QoZKrrxXzAhamhmwXZn/uVOrasLJ6CljRbGEcDiJSUnb8vGJNSRPAKLRp1z/8jQMODSm3Y12hk7IabaIUM7kc/dqRkjFMu2AwA01ACdnPlL++zdNpfe7quQzdKpp9t+X7RyyQk+hQ3rtMMjf6bBQKmOEqInCiRex2ozyshCePcxFTvt/HLsZRNj4QdZ0IbcDz/RMp6oni+dGtzMLN8/FQGvwrEeMRDXpauOD0DfYeNcLOXbICKgfu887T0Q16GiW4oFnv/k0Tqf9BIEVU66vAziFwKCQZKTcCF3btgb6Jp1sB0kx1TvUc/n/ccgcWHFOcP6W6tS6t9ZpDalU7ldf2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by PH8PR11MB7119.namprd11.prod.outlook.com (2603:10b6:510:215::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.21; Tue, 17 Oct 2023 17:08:33 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::68fb:c3f4:75e7:5fb5]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::68fb:c3f4:75e7:5fb5%4]) with mapi id 15.20.6886.034; Tue, 17 Oct 2023 17:08:33 +0000 Date: Tue, 17 Oct 2023 18:08:27 +0100 From: Bruce Richardson To: David Marchand CC: , Subject: Re: [PATCH v4 0/7] document and simplify use of cmdline Message-ID: References: <20230802170052.955323-1-bruce.richardson@intel.com> <20231016140612.664853-1-bruce.richardson@intel.com> Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: DU2PR04CA0177.eurprd04.prod.outlook.com (2603:10a6:10:2b0::32) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|PH8PR11MB7119:EE_ X-MS-Office365-Filtering-Correlation-Id: bf0b2dea-4b4e-42c9-07be-08dbcf33b172 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OWul8kDjVJE1EXa2on6YTRn8BCLsLOxn+3kbn1jO/dGSxB9UOeI54SE/boLXb3pJbUgj/dE0vf6wUXFLaBF6cKwKU9FonaCOHUSuYeo7MLEsxW1ExncVwSTgrDKTvSIBXxOotmaHTm5JDuE+Tr2/IcE0iGc1uPDNiW0rdqjU/VvxttKZ9SY84iXULvqqBeD+HGiaMU67Rx9mBw2shJPnApppJBp4E9DK/vsjrqBXWrjHu1/i8haXeuukbO34LTTzewerPCyBilpgjZQwJH+tU0SmH+xxJpSP8cAykSV7Xx/btykj8FZfeMbsUbwv1Aw01+cMN0kCy1D9URHvv8wXjO/S5RxTptdVTgRFau7bqedz8T3dXp7jYFt2esEht0PGJ2viTgNTI9l1XdTmRUeMOr7IYksdDSri/Pk2sTZJxPrJTiad3whWQAdQCtaAeHusKpn5Gy4mFAEnwmw3VaQp09DU79i6NY6nEdWvWYpjcGkU/zuSiorBVsADGAgnO759XC/tQzikwvNTLarGbSvbQuqDexskJW4sphOfNjPtY69H389O6HWNFaBUKylh7c6/ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(366004)(346002)(39860400002)(396003)(376002)(230922051799003)(1800799009)(186009)(64100799003)(451199024)(478600001)(6486002)(66556008)(66476007)(316002)(6916009)(66946007)(26005)(86362001)(82960400001)(83380400001)(38100700002)(6506007)(53546011)(6666004)(6512007)(2906002)(41300700001)(5660300002)(8676002)(8936002)(4326008)(44832011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZVBZQ3pxdTN6ZFVXNTIwZEI3bmNnaDBUT0lrS09EZFhkM3ByUXpwOHB1Ky9r?= =?utf-8?B?dDV2U1Z2UmQ1YzZvU2t3ODcvT2hDZ2pVS3FkY2gyVEcvU2dOK3RkWFNEU0tK?= =?utf-8?B?VjVRUmxkZE9naGdrZ2NFc1RJVFRqbmFlekxUcExLd2grUXVsTlNjUzVIWXZM?= =?utf-8?B?cnlrYVFncEpQN1lkRFdsQ0grSU9UVmd5ZFZiUFR3WEFNSUxQcVBRVlFIWFgz?= =?utf-8?B?c0FlQURUOGtGbnlpRCtKbHY1V29hVUloZDk2dFd5aUxkS1RYKzJrZ29mUjQ5?= =?utf-8?B?VCt5NncwTjZnc0k0TkZmUUlVQWhjcTRLMlByQmlCbUdQdGJhVUgvMDNEMnpv?= =?utf-8?B?aDl1UWU4eUhpR2N5VmhOR29nb2s3T1hiY0tVcE1idG1zdEhTQU56TFNlUEVu?= =?utf-8?B?Yzl0UlpTZ3lOT3A4S3BiRUFTOWV2KytQWVJDcXQ0TTFzQVh0clpQRWdoWmFP?= =?utf-8?B?TUE0c0wzUUovZURRYjJuaFN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8?B?N1l2bTgybU91K1ZKU0R0SUlGb2Z4VGJqZWVkYUZPUlZ2d2M5YndKYnp5ME95?= =?utf-8?B?aUxBRG9zWVltd204bGVZK1ArM0RueThIa2RoTlg0cFArNW1Pa3NWeHh3bXlI?= =?utf-8?B?OFpWQWJ1T25SaEVGb3pSUFpGQXRhUlpyQXNGYlBBT2YvYWNKWnhUSnR5alJw?= =?utf-8?B?Zk4xOEk5clV4NVRsdW4zSkdSblozVUlhUlJlMEpJUFdZei9aT3NydDBYRWN0?= =?utf-8?B?aDUwTmcwbUtMKzNjMWtRUC9oUTJtN1lvSnN4d0ltWkw1eHg5ZVNVVVN1M0d4?= =?utf-8?B?RnRsVVBBb0lOcVNZUGg4M2dIa1owUDdmTU5aWitzV1lWei8vQTZoN0RXNjRB?= =?utf-8?B?UElRbW8wYWtML0hiUGZOQlcyZUdOZjBJWklCTWJ6dzduTkJLVktNcGh0VFNx?= =?utf-8?B?azlSbzVlTEN1NVBRMzZlclZLNy9PSEtuMGE5QmtWMkx1QjM1QXVvaGJFTVZl?= =?utf-8?B?L1p3UWQvb2FvU0hRLzA3RHYvM2V0SmdjZXNFVkRQZzYwbm0rRXJaL0I0enIz?= =?utf-8?B?dFUyUkpNOS9qM3lDNFU0c2tQNzZnWnlOQ2t5ZmdramNQcHc3TUtBeGhBS0Y3?= =?utf-8?B?WVQ2a3V3b0ZKcVh6S2wyM2FNbkhLS2ZwMmZIWkVUbFI1VnhNVFlNN25DNGNH?= =?utf-8?B?bW05emdRZWZRNVBRSXpPTmI5aXJ4MXN6bUxEaUI2SUZOZzFhOTNoRDh5c2lD?= =?utf-8?B?UFhFQWtTeWYrRzBtUzdoTHRua3BCNzF3cElDSE5zMG04c2t3SE1QS2xld2sy?= =?utf-8?B?UkE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: bf0b2dea-4b4e-42c9-07be-08dbcf33b172 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 17:08:33.3005 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HzSPQbk59nCp+dQ5NN/JGoZ0CoaBMcd3ifbnl/AQnzi6OMoYVblGJzTdyi7iaiPwBIXZit8OxK5gI4IgCewcn27vu9hVRDXjzyKv+IYgl3I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB7119 X-OriginatorOrg: intel.com 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 On Tue, Oct 17, 2023 at 06:23:47PM +0200, David Marchand wrote: > On Tue, Oct 17, 2023 at 10:29 AM Bruce Richardson > wrote: > > > > > > - testpmd accepts both "help" and "help
" commands. > > > But the cmdline library does not provide a way (afair) for specifiying > > > this "optional" aspect. > > > > > > And it can't be expressed with this series current syntax since > > > generated symbols would conflict if we ask for two "help" commands. > > > > > > My quick hack was to introduce a way to select the prefix of the > > > generated symbols. > > > There may be a better way, like finding a better discriminant for > > > naming symbols... > > > But, on the other hand, the symbols prefix might be something a > > > developer wants to control (instead of currently hardcoded cmd_ > > > prefix). > > > > > > @@ -20,6 +20,12 @@ def process_command(tokens, cfile, comment): > > > """Generate the structures and definitions for a single command.""" > > > name = [] > > > > > > + prefix, sep, cmd_name = tokens[0].partition(':') > > > + if cmd_name: > > > + tokens[0] = cmd_name > > > + else: > > > + prefix = 'cmd' > > > + > > > if tokens[0].startswith('<'): > > > print('Error: each command must start with at least one > > > literal string', file=sys.stderr) > > > sys.exit(1) > > > > > > (etc... I am not copying the rest of the diff) > > > > > > I then used as: > > > > > > cmd_brief:help # help: Show help > > > help section # help: Show help > > > > > > > Interesting. I actually had no plans to even consider moving something like > > testpmd over. However, this is an interesting one, though I'm not really > > Given the extensive use of the cmdline library in testpmd, it is a > good way to identify the limits of this series :-). > > > > sure I like it that much as a feature :-) I rather like having unique > > prefixes for each command. I wasn't actually aware of the testpmd "help > >
" command at all. I will have to look into it. > > Let me propose an alternative hack. > I mentionned previously that we could have a better namespace / > discriminant for those symbols, and it seems easier than I thought: > > @@ -25,8 +25,10 @@ def process_command(tokens, cfile, comment): > sys.exit(1) > for t in tokens: > if t.startswith('<'): > - break > - name.append(t) > + t_type, t_name = t[1:].split('>') > + name.append(t_name) > + else: > + name.append(t) > name = '_'.join(name) > > result_struct = [] > > With this, any command implementation symbol has the full chain of > token names as a prefix which will ensure there is no conflict. > WDYT? > Having thought a little more about it, I still don't like having the full command in all cases, but I can see it being useful for cases of overlapping prefixes. How about making it optional - setting a flag in the typename, or in the parameter name to indicate that it should be included in the overall command name. For example, if we prefix the variable name with "_" or "__", it could indicate that we can choose to include this. show port n --> void cmd_show_port_parsed(...) show port _n --> void cmd_show_port_n_parsed(...) Prefixes on strings beyond initial tokens could just be silently stripped. [Obviously open to other ideas on what form tagging could take] /Bruce