Not used for Avalon CLI git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/branches/avalon-implementation@529023 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-cli/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-cli/commit/a75fffaf Tree: http://git-wip-us.apache.org/repos/asf/commons-cli/tree/a75fffaf Diff: http://git-wip-us.apache.org/repos/asf/commons-cli/diff/a75fffaf Branch: refs/heads/avalon-implementation Commit: a75fffafadbb7f6ce99841ed8697c9b664517a38 Parents: 46bacc0 Author: Sebastian Bazley <[email protected]> Authored: Sun Apr 15 17:23:46 2007 +0000 Committer: Sebastian Bazley <[email protected]> Committed: Sun Apr 15 17:23:46 2007 +0000 ---------------------------------------------------------------------- xdocs/examples/ant.xml | 300 ------------------------------------------ xdocs/examples/cp.xml | 35 ----- xdocs/examples/cvs.xml | 35 ----- xdocs/examples/index.xml | 42 ------ xdocs/examples/ls.xml | 35 ----- 5 files changed, 447 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-cli/blob/a75fffaf/xdocs/examples/ant.xml ---------------------------------------------------------------------- diff --git a/xdocs/examples/ant.xml b/xdocs/examples/ant.xml deleted file mode 100644 index 8b135b3..0000000 --- a/xdocs/examples/ant.xml +++ /dev/null @@ -1,300 +0,0 @@ -<?xml version="1.0"?> -<!-- - Copyright 2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<document> - - <properties> - <author email="[email protected]">commons-dev</author> - <title>Examples - ant</title> - </properties> - - <body> - <section name="ant"> - <p> - This example works through modelling Apache Ant using CLI2, the - example is based on Apache Ant version 1.6.1 compiled on February 12 - 2004. - </p> - <p> - "Apache Ant is a Java-based build tool. In theory, it is kind of like - Make, but without Make's wrinkles." - For more information please - visit <a href="http://ant.apache.org/">http://ant.apache.org/</a> - </p> - <subsection name="Modelling"> - <p> - To model the ant options we first need to create some Builders so that - each of the option instances can be created: - </p> -<source>final DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); -final ArgumentBuilder abuilder = new ArgumentBuilder(); -final GroupBuilder gbuilder = new GroupBuilder();</source> - <p> - For each option we create an Option instance that will model it, built - using the Builder instances above: - </p> -<source>Option help = - obuilder - .withShortName("help") - .withShortName("h") - .withDescription("print this message") - .create(); -Option projecthelp = - obuilder - .withShortName("projecthelp") - .withShortName("p") - .withDescription("print project help information") - .create(); -Option version = - obuilder - .withShortName("version") - .withDescription("print the version information and exit") - .create(); -Option diagnostics = - obuilder - .withShortName("diagnostics") - .withDescription("print information that might be helpful to diagnose or report problems.") - .create(); -Option quiet = - obuilder - .withShortName("quiet") - .withShortName("q") - .withDescription("be extra quiet") - .create(); -Option verbose = - obuilder - .withShortName("verbose") - .withShortName("v") - .withDescription("be extra verbose") - .create(); -Option debug = - obuilder - .withShortName("debug") - .withShortName("d") - .withDescription("print debugging information") - .create(); -Option emacs = - obuilder - .withShortName("emacs") - .withShortName("e") - .withDescription("produce logging information without adornments") - .create(); -Option lib = - obuilder - .withShortName("lib") - .withDescription("specifies a path to search for jars and classes") - .withArgument( - abuilder - .withName("path") - .withMinimum(1) - .withMaximum(1) - .create()) - .create(); -Option logfile = - obuilder - .withShortName("logfile") - .withShortName("l") - .withDescription("use given file for log") - .withArgument( - abuilder - .withName("file") - .withMinimum(1) - .withMaximum(1) - .create()) - .create(); -Option logger = - obuilder - .withShortName("logger") - .withDescription("the class which is to perform logging") - .withArgument( - abuilder - .withName("classname") - .withMinimum(1) - .withMaximum(1) - .create()) - .create(); -Option listener = - obuilder - .withShortName("listener") - .withDescription("add an instance of class as a project listener") - .withArgument( - abuilder - .withName("classname") - .withMinimum(1) - .withMaximum(1) - .create()) - .create(); -Option noinput = - obuilder - .withShortName("noinput") - .withDescription("do not allow interactive input") - .create(); -Option buildfile = - obuilder - .withShortName("buildfile") - .withShortName("file") - .withShortName("f") - .withDescription("use given buildfile") - .withArgument( - abuilder - .withName("file") - .withMinimum(1) - .withMaximum(1) - .create()) - .create(); -Option property = new PropertyOption(); -Option propertyfile = - obuilder - .withShortName("propertyfile") - .withDescription("load all properties from file with -D properties taking precedence") - .withArgument( - abuilder - .withName("name") - .withMinimum(1) - .withMaximum(1) - .create()) - .create(); -Option inputhandler = - obuilder - .withShortName("inputhandler") - .withDescription("the class which will handle input requests") - .withArgument( - abuilder - .withName("class") - .withMinimum(1) - .withMaximum(1) - .create()) - .create(); -Option find = - obuilder - .withShortName("find") - .withShortName("s") - .withDescription("search for buildfile towards the root of the filesystem and use it") - .withArgument( - abuilder - .withName("file") - .withMinimum(1) - .withMaximum(1) - .create()) - .create(); -Option targets = abuilder.withName("target").create();</source> - <p> - We now create a Group instance consisting of all the above options: - </p> -<source>Group options = - gbuilder - .withName("options") - .withOption(help) - .withOption(projecthelp) - .withOption(version) - .withOption(diagnostics) - .withOption(quiet) - .withOption(verbose) - .withOption(debug) - .withOption(emacs) - .withOption(lib) - .withOption(logfile) - .withOption(logger) - .withOption(listener) - .withOption(noinput) - .withOption(buildfile) - .withOption(property) - .withOption(propertyfile) - .withOption(inputhandler) - .withOption(find) - .withOption(targets) - .create();</source> - </subsection> - <subsection name="Querying"> - <p> - Once the model is built, a CommandLine needs to be parsed: - </p> -<source>Parser parser = new Parser(); -parser.setGroup(options); -CommandLine cl = parser.parse(args);</source> - <p> - The CommandLine can be tested for the presence of options using the - hasOption() methods which take either an option instance or a trigger - value to lookup against: - </p> -<source>if(cl.hasOption(help)) { - //displayHelp(); - return; -} -if(cl.hasOption("-version")) { - //displayVersion(); - return; -}</source> - <p> - For those options that have an argument, the argument needs to be - extracted and processed: - </p> -<source>if(cl.hasOption(logfile)) { - String file = (String)cl.getValue(logfile); - //setLogFile(file); -}</source> - <p> - Each target for ant to process could then be processed in order as - specified: - </p> -<source>List targetList = cl.getValues(targets); -for (Iterator i = targetList.iterator(); i.hasNext();) { - String target = (String) i.next(); - //doTarget(target); -}</source> - </subsection> - <subsection name="Helping"> - <p> - To generate a help page for ant we first need to create a - HelpFormatter and set some basic properties. The shell command is - the command that the used would have typed to invoke the application, - and the group is the group of options that compose the model. - </p> -<source>HelpFormatter hf = new HelpFormatter(); -hf.setShellCommand("ant"); -hf.setGroup(options);</source> - <p> - The first section of help will display the full usage string for the - application, the appearence of this line can be adjusted using the - HelpFormatter's fullUsageSettings property: - </p> -<source>hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_GROUP_NAME); -hf.getFullUsageSettings().add(DisplaySetting.DISPLAY_GROUP_ARGUMENT); -hf.getFullUsageSettings().remove(DisplaySetting.DISPLAY_GROUP_EXPANDED);</source> - <p> - The main body of the help is based on a line or more of information - about each option in the model. DisplaySettings can be used again to - adjust which items are included in this display and which aren't. In - this case, we don't want to display any groups as the top one is the - only one present and can be inferred: - </p> -<source>hf.getDisplaySettings().remove(DisplaySetting.DISPLAY_GROUP_ARGUMENT);</source> - <p> - Each of the options identified by the displaySettings above has some - usage information displayed, usually this will be a minimal set of - DisplaySettings but these can be adjusted to get the desired effect: - </p> -<source>hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_PROPERTY_OPTION); -hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_PARENT_ARGUMENT); -hf.getLineUsageSettings().add(DisplaySetting.DISPLAY_ARGUMENT_BRACKETED);</source> - <p> - Finally, the help can be printed to System.out with a simple call to - <code>print()</code>: - </p> -<source>hf.print();</source> - </subsection> - </section> - </body> -</document> http://git-wip-us.apache.org/repos/asf/commons-cli/blob/a75fffaf/xdocs/examples/cp.xml ---------------------------------------------------------------------- diff --git a/xdocs/examples/cp.xml b/xdocs/examples/cp.xml deleted file mode 100644 index dfc6574..0000000 --- a/xdocs/examples/cp.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- - Copyright 2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<document> - - <properties> - <author email="[email protected]">commons-dev</author> - <title>Examples - cp</title> - </properties> - - <body> - <section name="cp"> - <p>TODO what is cp</p> - <subsection name="Modelling"> - </subsection> - <subsection name="Querying"> - </subsection> - <subsection name="Helping"> - </subsection> - </section> - </body> -</document> http://git-wip-us.apache.org/repos/asf/commons-cli/blob/a75fffaf/xdocs/examples/cvs.xml ---------------------------------------------------------------------- diff --git a/xdocs/examples/cvs.xml b/xdocs/examples/cvs.xml deleted file mode 100644 index 34009c1..0000000 --- a/xdocs/examples/cvs.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- - Copyright 2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<document> - - <properties> - <author email="[email protected]">commons-dev</author> - <title>Examples - cvs</title> - </properties> - - <body> - <section name="cvs"> - <p>TODO what is cvs</p> - <subsection name="Modelling"> - </subsection> - <subsection name="Querying"> - </subsection> - <subsection name="Helping"> - </subsection> - </section> - </body> -</document> http://git-wip-us.apache.org/repos/asf/commons-cli/blob/a75fffaf/xdocs/examples/index.xml ---------------------------------------------------------------------- diff --git a/xdocs/examples/index.xml b/xdocs/examples/index.xml deleted file mode 100644 index aa0476f..0000000 --- a/xdocs/examples/index.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0"?> -<!-- - Copyright 2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<document> - - <properties> - <author email="[email protected]">commons-dev</author> - <title>Examples</title> - </properties> - - <body> - <section name="Overview"> - <p> - The examples section aims to show how a variety of applications and - tools could be modelled using CLI2. We make no claim that these tools - use CLI2 in their implementation but simply use their interfaces to - demonstrate commonly needed features. Some examples will make - simplifications to keep the documentation consise. - </p> - <p> - Many aspects of the API are touched upon but few are described in - great detail. If more information is required then the reader is - encouraged to review the API documentation and look at the unit tests - for inspiration. Failing that, further advice and discussion can be - found on the <code>[email protected]</code> mailing list. - </p> - </section> - </body> -</document> http://git-wip-us.apache.org/repos/asf/commons-cli/blob/a75fffaf/xdocs/examples/ls.xml ---------------------------------------------------------------------- diff --git a/xdocs/examples/ls.xml b/xdocs/examples/ls.xml deleted file mode 100644 index fbb55ba..0000000 --- a/xdocs/examples/ls.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<!-- - Copyright 2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<document> - - <properties> - <author email="[email protected]">commons-dev</author> - <title>Examples - ls</title> - </properties> - - <body> - <section name="ls"> - <p>TODO what is ls</p> - <subsection name="Modelling"> - </subsection> - <subsection name="Querying"> - </subsection> - <subsection name="Helping"> - </subsection> - </section> - </body> -</document>
