This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 95918cca14cf9081aad782c4c82ab3b40ef4f74b
Author: quanth <[email protected]>
AuthorDate: Mon Oct 12 15:21:35 2020 +0700

    JAMES-XXXX Webadmin CLI help commands
---
 server/pom.xml                                     |  2 +
 server/protocols/webadmin-cli/pom.xml              | 87 ++++++++++++++++++++++
 .../java/org/apache/james/cli/WebAdminCli.java     | 52 +++++++++++++
 .../apache/james/cli/HelpVersionCommandTest.java   | 54 ++++++++++++++
 4 files changed, 195 insertions(+)

diff --git a/server/pom.xml b/server/pom.xml
index a152c6a..cc7c860 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -96,6 +96,7 @@
         <module>protocols/protocols-pop3</module>
         <module>protocols/protocols-smtp</module>
         <module>protocols/webadmin</module>
+        <module>protocols/webadmin-cli</module>
         <module>protocols/webadmin-integration-test</module>
 
         <module>queue/queue-activemq</module>
@@ -111,6 +112,7 @@
         <module>task/task-memory</module>
 
         <module>testing</module>
+
     </modules>
 
     <properties>
diff --git a/server/protocols/webadmin-cli/pom.xml 
b/server/protocols/webadmin-cli/pom.xml
new file mode 100644
index 0000000..5b010ed
--- /dev/null
+++ b/server/protocols/webadmin-cli/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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 xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>james-server</artifactId>
+        <groupId>org.apache.james</groupId>
+        <version>3.6.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <name>Apache James :: Server :: Web Admin CLI</name>
+    <description>James Webadmin based CLI</description>
+    <artifactId>webadmin-cli</artifactId>
+
+
+
+    <dependencies>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>testing-base</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>info.picocli</groupId>
+            <artifactId>picocli</artifactId>
+            <version>4.5.1</version>
+        </dependency>
+        <dependency>
+            <groupId>net.javacrumbs.json-unit</groupId>
+            <artifactId>json-unit-assertj</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <archive>
+                                <manifest>
+                                    <mainClass>
+                                        org.apache.james.cli.WebAdminCli
+                                    </mainClass>
+                                </manifest>
+                            </archive>
+                            <descriptorRefs>
+                                
<descriptorRef>jar-with-dependencies</descriptorRef>
+                            </descriptorRefs>
+                            <finalName>james-cli</finalName>
+                            <appendAssemblyId>false</appendAssemblyId>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>
\ No newline at end of file
diff --git 
a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java
 
b/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java
new file mode 100644
index 0000000..895d617
--- /dev/null
+++ 
b/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java
@@ -0,0 +1,52 @@
+/******************************************************************
+ * 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.                                             *
+ ******************************************************************/
+
+package org.apache.james.cli;
+
+import java.util.concurrent.Callable;
+
+import picocli.CommandLine;
+
[email protected](
+        name = "james-cli",
+        description = "James Webadmin CLI")
+public class WebAdminCli implements Callable<Integer> {
+
+    @Override
+    public Integer call() {
+        return 0;
+    }
+
+    public static void main(String[] args) {
+        int exitCode = execute(args);
+        System.exit(exitCode);
+    }
+
+    public static int execute(String[] args) {
+        WebAdminCli parent = new WebAdminCli();
+        return new CommandLine(parent)
+                .addSubcommand(new CommandLine.HelpCommand())
+                .execute(args);
+    }
+
+    public static int executeFluent(String... args) {
+        return execute(args);
+    }
+
+}
diff --git 
a/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java
 
b/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java
new file mode 100644
index 0000000..1d8c5cd
--- /dev/null
+++ 
b/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java
@@ -0,0 +1,54 @@
+/******************************************************************
+ * 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.                                             *
+ ******************************************************************/
+
+package org.apache.james.cli;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class HelpVersionCommandTest {
+
+    private final PrintStream standardOut = System.out;
+    private final ByteArrayOutputStream outputStreamCaptor = new 
ByteArrayOutputStream();
+
+    @BeforeEach
+    void setup() {
+        System.setOut(new PrintStream(outputStreamCaptor));
+    }
+
+    @AfterEach
+    void tearDown() {
+        System.setOut(standardOut);
+    }
+
+    @Test
+    void helpCommandShouldShowHelpMessage() {
+        int exitCode = WebAdminCli.executeFluent("help");
+        assertThat(exitCode).isEqualTo(0);
+        assertThat(outputStreamCaptor.toString()).contains("help");
+        assertThat(outputStreamCaptor.toString()).contains("Displays help 
information about the specified command");
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to