From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier MATZ Subject: Re: Question about librte_cmdline Date: Fri, 14 Nov 2014 12:14:00 +0100 Message-ID: <5465E3F8.5070606@6wind.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable To: Igor Ryzhov , "dev-VfR2kkLFssw@public.gmane.org" Return-path: In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Hi Igor, Adding-back the list to the discussion, I removed it by mistake in my first answer. >> 14 =D0=BD=D0=BE=D1=8F=D0=B1. 2014 =D0=B3., =D0=B2 12:20, Olivier MATZ = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0= ): >> >> Hi Igor, >> >> On 11/14/2014 09:52 AM, Igor Ryzhov wrote: >>> Are there any docs with detailed description of cmdline library? >>> I found only some information in =C2=ABDPDK Sample Apps=C2=BB documen= t, but it describes only a couple of features. >> >> In my knowledge, there is no such documentation. >> You can also refer to testpmd that gives a lot of different commands. >> >> If you have any question, you can ask on the list. >> >> Regards, >> Olivier >=20 > Thank you, I=E2=80=99ll check testpmd. >=20 > At the moment I have a question - is there a possibility to have option= al tokens in one command? >=20 > For example: >=20 > I have one command - =C2=ABobject=C2=BB and two subcommands - =C2=ABadd= =C2=BB and =C2=ABdel=C2=BB: >=20 > object add name IP > object del name >=20 > And the question is - can I have just one context instruction for this?= Something like that: >=20 > Result struct: >=20 > struct object_result { > cmdline_fixed_string_t object; > cmdline_fixed_string_t cmd; > cmdline_fixed_string_t name; > cmdline_ipaddr_t ip; // I need it optional - only for =C2=ABadd=C2=BB= case > } >=20 > And tokens: >=20 > cmdline_parse_token_string_t object =3D > TOKEN_STRING_INITIALIZER(struct object_result, object, "object"); > cmdline_parse_token_string_t cmd =3D > TOKEN_STRING_INITIALIZER(struct object_result, cmd, "add#del"); > cmdline_parse_token_string_t name =3D > TOKEN_STRING_INITIALIZER(struct object_result, name, NULL); > cmdline_parse_token_ipaddr_t ip =3D > TOKEN_IPV4_INITIALIZER(struct object_result, ip, NULL); >=20 > As I understand investigating the code of sample application - all toke= ns are required (because there are two different instructions - for =C2=AB= add=C2=BB and for =C2=ABdel/show=C2=BB). > And in this example configuration there is no possibility for string =C2= =ABobject del name=C2=BB without last IP token. > So I need to have two different context instructions - one for =C2=ABad= d=C2=BB and one for =C2=ABdel=C2=BB. > Am I right? Right, there is no way to declare an optional token in one instruction. But if there are few case (ex: a "set" and a "show" intructions), you can factorize the structure and the callback function. There is an example in my latest TSO patch: http://dpdk.org/ml/archives/dev/2014-November/007962.html Regards, Olivier