Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 61209 invoked from network); 10 Jun 2003 17:35:44 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 10 Jun 2003 17:35:44 -0000 Received: (qmail 16959 invoked by uid 97); 10 Jun 2003 17:38:04 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 16952 invoked from network); 10 Jun 2003 17:38:03 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 10 Jun 2003 17:38:03 -0000 Received: (qmail 61001 invoked by uid 500); 10 Jun 2003 17:35:42 -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 9422 invoked from network); 9 Jun 2003 08:12:19 -0000 Date: Sun, 8 Jun 2003 21:06:31 +0100 Content-Type: text/plain; charset=US-ASCII; format=flowed Resent-Date: Mon, 9 Jun 2003 09:15:32 +0100 Content-Transfer-Encoding: quoted-printable Resent-Message-Id: Resent-To: commons-dev Mime-Version: 1.0 (Apple Message framework v552) Subject: [CLI] Support for CVS style command line From: John Keyes To: commons-dev Message-Id: <89D09439-9A52-11D7-9668-00039379521C@integralsource.com> Resent-From: John Keyes 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 - - - - - - - - - - - - - - - - - - - - - - - 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