You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2014/08/19 21:40:24 UTC

git commit: [MINDEXER-90] created CLI options reference

Repository: maven-indexer
Updated Branches:
  refs/heads/master 61a91b069 -> 7e7202d77


[MINDEXER-90] created CLI options reference

Project: http://git-wip-us.apache.org/repos/asf/maven-indexer/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-indexer/commit/7e7202d7
Tree: http://git-wip-us.apache.org/repos/asf/maven-indexer/tree/7e7202d7
Diff: http://git-wip-us.apache.org/repos/asf/maven-indexer/diff/7e7202d7

Branch: refs/heads/master
Commit: 7e7202d774596eea07a5c905e92b2e9b80a17543
Parents: 61a91b0
Author: Hervé Boutemy <hb...@apache.org>
Authored: Tue Aug 19 21:40:20 2014 +0200
Committer: Hervé Boutemy <hb...@apache.org>
Committed: Tue Aug 19 21:40:20 2014 +0200

----------------------------------------------------------------------
 indexer-cli/src/site/apt/index.apt.vm           | 34 ++++++++++
 .../maven/index/cli/NexusIndexerCliTest.java    | 66 ++++++++++++++++++++
 2 files changed, 100 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/7e7202d7/indexer-cli/src/site/apt/index.apt.vm
----------------------------------------------------------------------
diff --git a/indexer-cli/src/site/apt/index.apt.vm b/indexer-cli/src/site/apt/index.apt.vm
new file mode 100644
index 0000000..6e4bd69
--- /dev/null
+++ b/indexer-cli/src/site/apt/index.apt.vm
@@ -0,0 +1,34 @@
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you 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.
+
+ -----
+ ${project.name}
+ -----
+ Hervé Boutemy
+ -----
+ 2014-08-19
+ -----
+
+${project.name}
+
+  ${project.description}
+
+* CLI Options Reference
+
+%{snippet|file=${project.basedir}/target/test-classes/options.html|verbatim=false}
+
+  Either unpack or index with <<<--repository>>> must be used.

http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/7e7202d7/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java
----------------------------------------------------------------------
diff --git a/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java b/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java
index 2d5255f..a04d0d8 100644
--- a/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java
+++ b/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java
@@ -19,9 +19,17 @@ package org.apache.maven.index.cli;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
 import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
 
+import org.apache.commons.cli.Option;
 import org.apache.maven.index.cli.NexusIndexerCli;
+import org.codehaus.plexus.util.FileUtils;
 
 public class NexusIndexerCliTest
     extends AbstractNexusIndexerCliTest
@@ -47,4 +55,62 @@ public class NexusIndexerCliTest
         return cli.execute( args );
     }
 
+    private final static String LS = System.getProperty( "line.separator" );
+
+    private static class OptionComparator
+        implements Comparator<Option>
+    {
+        public int compare( Option opt1, Option opt2 )
+        {
+            return opt1.getOpt().compareToIgnoreCase( opt2.getOpt() );
+        }
+    }
+
+    public String getOptionsAsHtml()
+    {
+        @SuppressWarnings( "unchecked" )
+        List<Option> optList = new ArrayList<Option>( new NexusIndexerCli().buildDefaultCliOptions().getOptions() );
+        Collections.sort( optList, new OptionComparator() );
+
+        StringBuilder sb = new StringBuilder();
+        boolean a = true;
+        sb.append( "<table border='1' class='zebra-striped'><tr class='a'><th><b>Options</b></th><th><b>Description</b></th></tr>" );
+        for ( Option option : optList )
+        {
+            a = !a;
+            sb.append( "<tr class='" ).append( a ? 'a' : 'b' ).append( "'><td><code>-<a name='" );
+            sb.append( option.getOpt() );
+            sb.append( "'>" );
+            sb.append( option.getOpt() );
+            sb.append( "</a>,--<a name='" );
+            sb.append( option.getLongOpt() );
+            sb.append( "'>" );
+            sb.append( option.getLongOpt() );
+            sb.append( "</a>" );
+            if ( option.hasArg() )
+            {
+                if ( option.hasArgName() )
+                {
+                    sb.append( " &lt;" ).append( option.getArgName() ).append( "&gt;" );
+                }
+                else
+                {
+                    sb.append( ' ' );
+                }
+            }
+            sb.append( "</code></td><td>" );
+            sb.append( option.getDescription() );
+            sb.append( "</td></tr>" );
+            sb.append( LS );
+        }
+        sb.append( "</table>" );
+        return sb.toString();
+    }
+
+    public void testOptionsAsHtml()
+        throws IOException
+    {
+        File options = getTestFile( "target/test-classes/options.html" );
+        FileUtils.fileWrite( options, "UTF-8", getOptionsAsHtml() );
+    }
 }