Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 12307 invoked from network); 9 Jun 2003 08:15:53 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 9 Jun 2003 08:15:53 -0000 Received: (qmail 26320 invoked by uid 97); 9 Jun 2003 08:18:19 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 26313 invoked from network); 9 Jun 2003 08:18:19 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 9 Jun 2003 08:18:19 -0000 Received: (qmail 12066 invoked by uid 500); 9 Jun 2003 08:15:50 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 12055 invoked from network); 9 Jun 2003 08:15:50 -0000 Received: from smtpout.mac.com (17.250.248.86) by daedalus.apache.org with SMTP; 9 Jun 2003 08:15:50 -0000 Received: from mac.com (smtpin07-en2 [10.13.10.152]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id h598G2xo025654 for ; Mon, 9 Jun 2003 01:16:03 -0700 (PDT) Received: from mac.com (k100-164.bas1.dbn.dublin.eircom.net [159.134.100.164]) (authenticated bits=0) by mac.com (Xserve/8.12.9/MantshX 2.0) with ESMTP id h598Fx05025077 for ; Mon, 9 Jun 2003 01:16:01 -0700 (PDT) Date: Mon, 9 Jun 2003 09:18:56 +0100 Mime-Version: 1.0 (Apple Message framework v552) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: [CLI] Support for CVS style command line From: John Keyes To: commons-dev Content-Transfer-Encoding: quoted-printable Message-Id: <03DF2711-9A53-11D7-9668-00039379521C@mac.com> X-Mailer: Apple Mail (2.552) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N The CVS command line is defined as follows: cvs [options] command [command-options] Ideally I would like to have CLI support this implicity, i.e. validate the 'command' value (this was a feature already recommended by Mike McLean and modified by Max Rydahl Andersen) and based on this value parse the remaining Options. There are two steps in this: . value validation . mapping value to Options So here's an example: ValueValidator commandValidator =3D new StringValidator() { public boolean validate(String value) { ... } } OptionsMap optionsMap =3D new OptionsMap(); optionsMap.add("checkout", checkoutOptions); optionsMap.add("co", checkoutOptions); // this means that there is an Anonymous Argument which will // have one value and the HelpFormatter will spit 'command' // out in the help text, the value found in the args will // be validated by the specified validator Argument command =3D abuilder.withOptionMap(optionsMap) .withValidator(commandValidator) .createAnonymous("command",1); =00 // args - "cvs co file.txt" CommandLine line =3D parser.parse(opts, args); The parse would find 'co' as the Anonymous Argument, and then validate that the value is allowable, when it confirms that it is valuable then query the OptionsMap to see if there are any Options specified for that value. If there are Options, then parse the remaining args (file.txt) using them. If there are no Options, then throw an exception as there is only one value allowed for the anonymous argument. What do people think of this? Does it sound good? Are there any better ideas? Cheers, -John K - - - - - - - - - - - - - - - - - - - - - - - Jakarta Commons CLI http://jakarta.apache.org/commons/cli= --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org