From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Wiles, Keith" Subject: Re: [RFC] cmdline: rework as a wrapper to libedit Date: Wed, 15 Nov 2017 04:12:07 +0000 Message-ID: <48C2CD08-29E1-444C-BF60-B96BE58865A5@intel.com> References: <1510234868-31053-1-git-send-email-adrien.mazarguil@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: Olivier Matz , "Wu, Jingjing" , "dev@dpdk.org" , Thomas Monjalon , "Yigit, Ferruh" To: Adrien Mazarguil Return-path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id F17D91B162 for ; Wed, 15 Nov 2017 05:12:09 +0100 (CET) In-Reply-To: <1510234868-31053-1-git-send-email-adrien.mazarguil@6wind.com> Content-Language: en-US Content-ID: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > On Nov 9, 2017, at 5:43 AM, Adrien Mazarguil = wrote: >=20 > This patch removes all code associated with symbols not internally relied > on by other DPDK components, makes struct cmdline opaque and then proceed= s > to re-implement the remaining functionality as a wrapper to the editline > library (also known as libedit) [1]. >=20 > Besides adding a new external dependency to its users, its large impact o= n > librte_cmdline's API/ABI also warrants a major version number bump. >=20 > While librte_cmdline served DPDK well all these years as a small, easy to > use and self-sufficient interactive command-line handler, it started to > show its limits with testpmd's flow (rte_flow) command, which required > support for dynamic tokens and very long commands. >=20 > This is the main motivation behind this rework. Long commands often need = to > be displayed on multiple lines, which are not properly supported by > librte_cmdline's limited terminal handling capabilities, resulting in a > rather frustrating user experience. >=20 > Testpmd being one of the main tools used by PMD developers and given flow > command lines won't get any shorter, this issue had to be addressed. >=20 > Three options were considered: >=20 > - Fixing and enhancing librte_cmdline. >=20 > The amount of work necessary to add support for edition on multiple line= s > was deemed significant and the result would still have lacked in some > areas, such as working backspace/delete keys in all terminals (i.e. full > termcap support). >=20 > - Making testpmd directly rely on a more capable library. >=20 > All testpmd commands rely on the cmdline_parse interface provided by > librte_cmdline. This approach would have required either a complete > rewrite or importing the missing bits from librte_cmdline to wrap them > around the new library, which naturally led to... >=20 > - Converting librte_cmdline as a wrapper to a more capable library. >=20 > Let's be honest, interactive command line handling isn't what makes DPDK > shine. It's also far removed from its core functionality, but is still > necessary in order to easily implement test and example programs; the > cmdline_parse interface is particularly good at this. >=20 > DPDK actually only relies on cmdline_parse. By removing all the other > unused interfaces, implementing what remains on top of a different > terminal-handling library would be quick and easy. >=20 > This last approach was chosen for the stated reasons. Libedit is > well-known, BSD-licensed, widely available [2], used by many projects, do= es > everything needed and more [3]. >=20 > This rework results in the following changes: >=20 > - Removed circular buffer management interface for command history > (cmdline_cirbuf.c), command history being handled by libedit. > - Removed raw command-line interpreter (cmdline_rdline.c). > - Removed raw terminal handler (cmdline_vt100.c). > - Removed all test/example code for the above. > - Re-implemented high level interactive and non-interactive command-line > handlers (cmdline.c and cmdline_socket.c) on top of libedit using its > native interface, not its readline compatibility layer. > - Made struct cmdline opaque so that applications relying on librte_cmdli= ne > do not need to include any libedit headers. > - The only visible change for most applications besides being linked to > libedit is they do not have to include cmdline_rdline.h anymore. >=20 > As an added bonus, terminal resizing is now automatically handled. >=20 > In the future, cmdline_parse could use libedit's advanced tokenizer as > well to interpret quoted strings and escape sequences. >=20 I do agree that cmdline is getting pretty old and using libedit is one solu= tion around the long commands, but it has a lot more problems IMO. I do not agree it has severed DPDK well, just look at test-pmd and the hoop= s people have to jump thru to get a new command or variation of an existing= command integrated into test-pmd it is very difficult. Also if you look at= the command sets in test-pmd they are very odd in that similar commands ca= n some times be set up completely different as cmdline is too rigid and dif= ficult to use. I had decided to not use the circular buffer code in cmdline as it did have= a few problems for what I wanted and decided to write a standard gap buffe= r scheme used in most editors for lines. I had looked at libedit at one poi= nt decided I did not want another dependence for DPDK. I expect even my ver= sion does not solve the long line problem, but we can convert to libedit. (= and toss my pretty code :-) Fixing the long line problem is a very minor issue compared to everything e= lse wrong with cmdline. I would suggest we look at CLI and improve it inste= ad. We can add libedit to CLI and then finish testing the CLI with test-pmd= . The first time I converted test-pmd I did remove and simplify the command= s, but I was afraid that would cause a lot of problems for testing and scri= pts that people have written, but it is possible to fix these problems too. I do not think fixing cmdline is the best answer and working to convert ove= r to CLI is the better answer here. Regards, Keith