[kune-commits] r1853 - in trunk: . core core/kune-cli core/kune-cli/.settings core/kune-cli/src/main/java/cc/kune/kunecli core/kune-cli/src/test/java core/kune-cli/src/test/java/cc core/kune-cli/src/test/java/cc/kune core/kune-cli/src/test/java/cc/kune/kunecli

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Tue Apr 17 02:58:52 CEST 2012


Author: vjrj_
Date: 2012-04-17 02:58:51 +0200 (Tue, 17 Apr 2012)
New Revision: 1853

Added:
   trunk/core/kune-cli/bin/
   trunk/core/kune-cli/src/test/java/cc/
   trunk/core/kune-cli/src/test/java/cc/kune/
   trunk/core/kune-cli/src/test/java/cc/kune/kunecli/
   trunk/core/kune-cli/src/test/java/cc/kune/kunecli/KuneCliMainTest.java
Removed:
   trunk/core/kune-cli/.settings/org.eclipse.jdt.core.prefs
Modified:
   trunk/core/kune-cli/.classpath
   trunk/core/kune-cli/.project
   trunk/core/kune-cli/pom.xml
   trunk/core/kune-cli/src/main/java/cc/kune/kunecli/KuneCliMain.java
   trunk/core/pom.xml
   trunk/pom.xml
Log:
NEW - # 240: Add a command cli to kune

Modified: trunk/core/kune-cli/.classpath
===================================================================
--- trunk/core/kune-cli/.classpath	2012-04-16 23:22:33 UTC (rev 1852)
+++ trunk/core/kune-cli/.classpath	2012-04-17 00:58:51 UTC (rev 1853)
@@ -1,9 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
   <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
-  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
-  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="var" path="M2_REPO/javax/inject/javax.inject/1/javax.inject-1.jar" sourcepath="M2_REPO/javax/inject/javax.inject/1/javax.inject-1-sources.jar"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
   <classpathentry kind="var" path="M2_REPO/org/naturalcli/naturalcli/1.2.3/naturalcli-1.2.3.jar" sourcepath="M2_REPO/org/naturalcli/naturalcli/1.2.3/naturalcli-1.2.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/googlecode/gwtrpccommlayer/0.0.1/gwtrpccommlayer-0.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/cc/kune/kune-services/0.2.0-SNAPSHOT/kune-services-0.2.0-SNAPSHOT.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.9/junit-4.9.jar" sourcepath="M2_REPO/junit/junit/4.9/junit-4.9-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/google/gwt/gwt-user/2.1.1/gwt-user-2.1.1.jar" sourcepath="M2_REPO/com/google/gwt/gwt-user/2.1.1/gwt-user-2.1.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/google/inject/guice/3.0/guice-3.0-no_aop.jar"/>
+  <classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/>
 </classpath>
\ No newline at end of file

Modified: trunk/core/kune-cli/.project
===================================================================
--- trunk/core/kune-cli/.project	2012-04-16 23:22:33 UTC (rev 1852)
+++ trunk/core/kune-cli/.project	2012-04-17 00:58:51 UTC (rev 1853)
@@ -1,17 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
   <name>kune-cli</name>
-  <comment>Kune command line interface</comment>
+  <comment>Kune command line interface. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
   <projects/>
   <buildSpec>
     <buildCommand>
       <name>org.eclipse.jdt.core.javabuilder</name>
     </buildCommand>
-    <buildCommand>
-      <name>org.eclipse.m2e.core.maven2Builder</name>
-    </buildCommand>
   </buildSpec>
   <natures>
     <nature>org.eclipse.jdt.core.javanature</nature>
-    <nature>org.eclipse.m2e.core.maven2Nature</nature>
   </natures>
 </projectDescription>
\ No newline at end of file

Deleted: trunk/core/kune-cli/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/core/kune-cli/.settings/org.eclipse.jdt.core.prefs	2012-04-16 23:22:33 UTC (rev 1852)
+++ trunk/core/kune-cli/.settings/org.eclipse.jdt.core.prefs	2012-04-17 00:58:51 UTC (rev 1853)
@@ -1,5 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.5

Modified: trunk/core/kune-cli/pom.xml
===================================================================
--- trunk/core/kune-cli/pom.xml	2012-04-16 23:22:33 UTC (rev 1852)
+++ trunk/core/kune-cli/pom.xml	2012-04-17 00:58:51 UTC (rev 1853)
@@ -1,4 +1,5 @@
-<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">
+<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">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <artifactId>kune-core</artifactId>
@@ -8,6 +9,12 @@
   </parent>
   <artifactId>kune-cli</artifactId>
   <description>Kune command line interface</description>
+  <repositories>
+    <repository>
+      <id>kune-maven</id>
+      <url>http://kune.ourproject.org/mavenrepo/</url>
+    </repository>
+  </repositories>
   <dependencies>
     <dependency>
       <groupId>org.naturalcli</groupId>
@@ -15,5 +22,68 @@
       <version>1.2.3</version>
       <scope>runtime</scope>
     </dependency>
+    <dependency>
+      <groupId>com.googlecode</groupId>
+      <artifactId>gwtrpccommlayer</artifactId>
+      <version>0.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>cc.kune</groupId>
+      <artifactId>kune-services</artifactId>
+      <version>0.2.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.9</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.google.gwt</groupId>
+      <artifactId>gwt-user</artifactId>
+      <version>${gwt.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpcore</artifactId>
+      <version>4.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>com.google.inject</groupId>
+      <artifactId>guice</artifactId>
+      <version>3.0</version>
+      <classifier>no_aop</classifier>
+    </dependency>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.2</version>
+        <executions>
+          <execution>
+            <phase>exec</phase>
+            <goals>
+              <goal>java</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <mainClass>cc.kune.kunecli.KuneCliMain</mainClass>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>
\ No newline at end of file

Modified: trunk/core/kune-cli/src/main/java/cc/kune/kunecli/KuneCliMain.java
===================================================================
--- trunk/core/kune-cli/src/main/java/cc/kune/kunecli/KuneCliMain.java	2012-04-16 23:22:33 UTC (rev 1852)
+++ trunk/core/kune-cli/src/main/java/cc/kune/kunecli/KuneCliMain.java	2012-04-17 00:58:51 UTC (rev 1853)
@@ -20,9 +20,13 @@
 
 package cc.kune.kunecli;
 
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.naturalcli.Command;
 import org.naturalcli.ExecutionException;
 import org.naturalcli.ICommandExecutor;
@@ -34,41 +38,106 @@
 import org.naturalcli.commands.HelpCommand;
 import org.naturalcli.commands.SleepCommand;
 
+import cc.kune.core.client.rpcservices.SiteServiceAsync;
+import cc.kune.core.client.rpcservices.UserServiceAsync;
+import cc.kune.core.shared.dto.InitDataDTO;
+import cc.kune.core.shared.dto.UserInfoDTO;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.googlecode.gwtrpccommlayer.client.GwtRpcService;
+import com.googlecode.gwtrpccommlayer.client.Module;
+
 public class KuneCliMain {
 
-  public static void main(String[] args) throws InvalidSyntaxException, ExecutionException {
-    Command showDateCommand =
-        new Command(
-          "hello world [<name:string>]", 
-          "Says hello to the world and, may be, especially to some one.", 
-          new ICommandExecutor ()
-          {
-            public void execute(ParseResult pr) 
-            {  
-              System.out.print("Hello world!");
-              String p0 = pr.getParameterValue(0).toString();
-              if (p0 == null)
-                System.out.println();
-              else
-                System.out.println(" And hello especially to "+p0);  
-            }
-          }   
-        );
+  private static final String SERVICE_PREFFIX = "http://127.0.0.1/ws/";
+  public static final Log LOG = LogFactory.getLog(KuneCliMain.class);
+  private static UserServiceAsync userService;
+  private static SiteServiceAsync siteService;
+
+  public static void main(String[] args) throws InvalidSyntaxException, ExecutionException,
+      MalformedURLException {
+
+    initServices();
+
+    Command showDateCommand = new Command("hello world [<name:string>]",
+        "Says hello to the world and, may be, especially to some one.", new ICommandExecutor() {
+          public void execute(ParseResult pr) {
+            System.out.print("Hello world!");
+            String p0 = pr.getParameterValue(0).toString();
+            if (p0 == null)
+              System.out.println();
+            else
+              System.out.println(" And hello especially to " + p0);
+          }
+        });
+
+    Command auth = new Command("auth <user:string> <pass:string>", "auth to kune",
+        new ICommandExecutor() {
+
+          public void execute(ParseResult pr) throws ExecutionException {
+            String user = pr.getParameterValue(0).toString();
+            String pass = pr.getParameterValue(1).toString();
+            userService.login(user, pass, "FIXME", new AsyncCallback<UserInfoDTO>() {
+
+              @Override
+              public void onSuccess(UserInfoDTO result) {
+                // TODO Auto-generated method stub
+              }
+
+              @Override
+              public void onFailure(Throwable caught) {
+                // TODO Auto-generated method stub
+              }
+            });
+          }
+        });
+
+    Command init = new Command("siteGetInitData", "gets the initial data", new ICommandExecutor() {
+      public void execute(ParseResult parseResult) throws ExecutionException {
+        siteService.getInitData("", new AsyncCallback<InitDataDTO>() {
+          @Override
+          public void onFailure(Throwable caught) {
+            // TODO Auto-generated method stub
+          }
+
+          @Override
+          public void onSuccess(InitDataDTO result) {
+            // TODO Auto-generated method stub
+          }
+        });
+      }
+    });
+
     // Create an empty command set
     Set<Command> cs = new HashSet<Command>();
-   
+
     // Create the interpreter
     NaturalCLI nc = new NaturalCLI(cs);
-   
+
     // Add the commands that can be understood
     cs.add(showDateCommand);
     cs.add(new HelpCommand(cs)); // help
     cs.add(new HTMLHelpCommand(cs)); // htmlhelp
-    cs.add(new SleepCommand());  // sleep <seconds:number> 
+    cs.add(new SleepCommand()); // sleep <seconds:number>
+    
+    // A script can be useful for kune  
     cs.add(new ExecuteFileCommand(nc)); // execute file <filename:string>
-   
-    // Execute the command line 
+
+    cs.add(init);
+    cs.add(auth);
+    // Execute the command line
     nc.execute(args, 0);
-     
   }
+
+  private static void initServices() throws MalformedURLException {
+    Injector injector = Guice.createInjector(new Module());
+
+    GwtRpcService service = injector.getInstance(GwtRpcService.class);
+
+    // TODO javadoc of this services
+    userService = service.create(new URL(SERVICE_PREFFIX + "UserService"), UserServiceAsync.class);
+    siteService = service.create(new URL(SERVICE_PREFFIX + "SiteService"), SiteServiceAsync.class);
+  }
 }

Added: trunk/core/kune-cli/src/test/java/cc/kune/kunecli/KuneCliMainTest.java
===================================================================
--- trunk/core/kune-cli/src/test/java/cc/kune/kunecli/KuneCliMainTest.java	                        (rev 0)
+++ trunk/core/kune-cli/src/test/java/cc/kune/kunecli/KuneCliMainTest.java	2012-04-17 00:58:51 UTC (rev 1853)
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright (C) 2007-2012 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * 
+ */
+package cc.kune.kunecli;
+
+import java.net.MalformedURLException;
+
+import org.junit.Test;
+import org.naturalcli.ExecutionException;
+import org.naturalcli.InvalidSyntaxException;
+
+public class KuneCliMainTest {
+  
+  @Test
+  public void basicHelp() throws InvalidSyntaxException, ExecutionException, MalformedURLException {
+    KuneCliMain cli = new KuneCliMain();
+    String[] args = new String[] {"auth", "admin", "easyeasy"};
+    cli.main(args);
+  }
+
+
+}

Modified: trunk/core/pom.xml
===================================================================
--- trunk/core/pom.xml	2012-04-16 23:22:33 UTC (rev 1852)
+++ trunk/core/pom.xml	2012-04-17 00:58:51 UTC (rev 1853)
@@ -5,13 +5,20 @@
   <artifactId>kune-core</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>pom</packaging>
+  <properties>
+    <maven.compiler.source>1.6</maven.compiler.source>
+    <maven.compiler.target>1.6</maven.compiler.target>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <wiab.version>0.3.13</wiab.version>
+    <gwt.version>2.1.1</gwt.version>
+  </properties>
   <modules>
     <module>kune-cli</module>
   </modules>
-<!--   <repositories> -->
-<!--     <repository> -->
-<!--       <id>kune-maven</id> -->
-<!--       <url>http://kune.ourproject.org/mavenrepo/</url> -->
-<!--     </repository> -->
-<!--   </repositories> -->
+  <!-- <repositories> -->
+  <!-- <repository> -->
+  <!-- <id>kune-maven</id> -->
+  <!-- <url>http://kune.ourproject.org/mavenrepo/</url> -->
+  <!-- </repository> -->
+  <!-- </repositories> -->
 </project>
\ No newline at end of file

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2012-04-16 23:22:33 UTC (rev 1852)
+++ trunk/pom.xml	2012-04-17 00:58:51 UTC (rev 1853)
@@ -1070,6 +1070,7 @@
               <classifier>services</classifier>
               <includes>
                 <include>**/rpcservices/UserService**</include>
+                <include>**/rpcservices/SiteService**</include>
                 <include>**/shared/domain/*</include>
                 <include>**/shared/domain/utils/*</include>
                 <include>**/shared/dto/*</include>




More information about the kune-commits mailing list