[seam-commits] Seam SVN: r13393 - in sandbox/encore: model and 16 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Jul 14 18:36:55 EDT 2010


Author: lincolnthree
Date: 2010-07-14 18:36:54 -0400 (Wed, 14 Jul 2010)
New Revision: 13393

Added:
   sandbox/encore/model/
   sandbox/encore/model/.classpath
   sandbox/encore/model/.project
   sandbox/encore/model/.settings/
   sandbox/encore/model/.settings/org.eclipse.jdt.core.prefs
   sandbox/encore/model/.settings/org.maven.ide.eclipse.prefs
   sandbox/encore/model/pom.xml
   sandbox/encore/model/src/
   sandbox/encore/model/src/main/
   sandbox/encore/model/src/main/java/
   sandbox/encore/model/src/main/java/org/
   sandbox/encore/model/src/main/java/org/jboss/
   sandbox/encore/model/src/main/java/org/jboss/encore/
   sandbox/encore/model/src/main/java/org/jboss/encore/model/
   sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java
   sandbox/encore/model/src/main/java/org/jboss/encore/model/MavenJavaProject.java
   sandbox/encore/model/src/main/java/org/jboss/encore/model/Project.java
   sandbox/encore/model/src/main/java/org/jboss/encore/model/events/
   sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileCreated.java
   sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileEvent.java
   sandbox/encore/model/src/main/java/org/jboss/encore/model/events/JavaFileCreated.java
   sandbox/encore/model/src/main/resources/
   sandbox/encore/model/src/main/resources/META-INF/
   sandbox/encore/model/src/main/resources/META-INF/beans.xml
   sandbox/encore/model/src/test/
   sandbox/encore/model/src/test/java/
   sandbox/encore/model/src/test/resources/
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java
Removed:
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java
Modified:
   sandbox/encore/pom.xml
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java
   sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java
Log:
Began project meta-model API, can remove methods from java files

Added: sandbox/encore/model/.classpath
===================================================================
--- sandbox/encore/model/.classpath	                        (rev 0)
+++ sandbox/encore/model/.classpath	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: sandbox/encore/model/.project
===================================================================
--- sandbox/encore/model/.project	                        (rev 0)
+++ sandbox/encore/model/.project	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>model</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+	</natures>
+</projectDescription>

Added: sandbox/encore/model/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- sandbox/encore/model/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ sandbox/encore/model/.settings/org.eclipse.jdt.core.prefs	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,6 @@
+#Wed Jul 14 14:23:58 EDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

Added: sandbox/encore/model/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- sandbox/encore/model/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ sandbox/encore/model/.settings/org.maven.ide.eclipse.prefs	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,9 @@
+#Wed Jul 14 14:23:58 EDT 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Added: sandbox/encore/model/pom.xml
===================================================================
--- sandbox/encore/model/pom.xml	                        (rev 0)
+++ sandbox/encore/model/pom.xml	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,33 @@
+<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/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+
+   <parent>
+      <artifactId>encore</artifactId>
+      <groupId>org.jboss.encore</groupId>
+      <version>1.0.0-SNAPSHOT</version>
+      <relativePath>../pom.xml</relativePath>
+   </parent>
+
+   <artifactId>model</artifactId>
+   <version>1.0.0-SNAPSHOT</version>
+
+   <packaging>jar</packaging>
+   <name>Encore Project Model APIs</name>
+   <description>Simplified project bootstrapping and incremental enhancement framework</description>
+
+   <dependencies>
+      <!-- Resource manipulation dependencies -->
+      <dependency>
+         <groupId>org.jboss.shrinkwrap</groupId>
+         <artifactId>shrinkwrap-api</artifactId>
+         <version>1.0.0-alpha-9</version>
+      </dependency>
+      <dependency>
+         <groupId>javax.enterprise</groupId>
+         <artifactId>cdi-api</artifactId>
+         <version>1.0</version>
+      </dependency>
+   </dependencies>
+
+</project>

Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java	                        (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/AbstractProject.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+import org.jboss.encore.model.events.JavaFileCreated;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+public abstract class AbstractProject implements Project
+{
+   @Inject
+   Event<JavaFileCreated> event;
+
+   public boolean createJavaFile(final String path, final byte[] data)
+   {
+      return createJavaFile(path, new ByteArrayInputStream(data));
+   }
+
+   public boolean createJavaFile(final String path, final InputStream data)
+   {
+      BufferedWriter writer = null;
+      try
+      {
+         File file = new File(path);
+         writer = new BufferedWriter(new FileWriter(file));
+         event.fire(new JavaFileCreated(file));
+         writer.close();
+         return true;
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+}

Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/MavenJavaProject.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/MavenJavaProject.java	                        (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/MavenJavaProject.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model;
+
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+public class MavenJavaProject extends AbstractProject
+{
+
+}

Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/Project.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/Project.java	                        (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/Project.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model;
+
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+public interface Project
+{
+}

Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileCreated.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileCreated.java	                        (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileCreated.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model.events;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+public class FileCreated extends FileEvent
+{
+   public FileCreated(final File file)
+   {
+      super(file);
+   }
+
+}

Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileEvent.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileEvent.java	                        (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/events/FileEvent.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model.events;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+public class FileEvent
+{
+   private final File file;
+
+   public FileEvent(final File file)
+   {
+      this.file = file;
+   }
+
+   public File getFile()
+   {
+      return file;
+   }
+}

Added: sandbox/encore/model/src/main/java/org/jboss/encore/model/events/JavaFileCreated.java
===================================================================
--- sandbox/encore/model/src/main/java/org/jboss/encore/model/events/JavaFileCreated.java	                        (rev 0)
+++ sandbox/encore/model/src/main/java/org/jboss/encore/model/events/JavaFileCreated.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.model.events;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ * 
+ */
+public class JavaFileCreated extends FileCreated
+{
+   public JavaFileCreated(final File file)
+   {
+      super(file);
+   }
+}

Added: sandbox/encore/model/src/main/resources/META-INF/beans.xml
===================================================================
--- sandbox/encore/model/src/main/resources/META-INF/beans.xml	                        (rev 0)
+++ sandbox/encore/model/src/main/resources/META-INF/beans.xml	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans>
+</beans>

Modified: sandbox/encore/pom.xml
===================================================================
--- sandbox/encore/pom.xml	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/pom.xml	2010-07-14 22:36:54 UTC (rev 13393)
@@ -13,6 +13,7 @@
 
    <modules>
       <module>core</module>
+      <module>model</module>
       <module>shell</module>
    </modules>
 

Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/Shell.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -160,4 +160,19 @@
    {
       return prompt("");
    }
+
+   public void clear()
+   {
+      try
+      {
+         String currentPrompt = reader.getPrompt();
+         reader.setPrompt("");
+         reader.clearScreen();
+         reader.setPrompt(currentPrompt);
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
 }
\ No newline at end of file

Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/CommandLibraryExtension.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -36,6 +36,7 @@
 
 import org.jboss.encore.shell.plugins.Command;
 import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
 import org.jboss.encore.shell.plugins.Option;
 import org.jboss.encore.shell.plugins.Plugin;
 import org.jboss.encore.shell.util.Annotations;
@@ -69,6 +70,11 @@
          pluginMeta.setName(name);
          pluginMeta.setType(plugin);
 
+         if (Annotations.isAnnotationPresent(plugin, Help.class))
+         {
+            pluginMeta.setHelp(Annotations.getAnnotation(plugin, Help.class).value());
+         }
+
          List<CommandMetadata> commands = getPluginCommands(pluginMeta, plugin);
          pluginMeta.setCommands(commands);
 

Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginCommandCompletionHandler.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -52,7 +52,7 @@
             String pluginName = p.getValue().getName();
             if (isPotentialMatch(pluginName, token))
             {
-               candidates.add(pluginName + " ");
+               candidates.add(pluginName);
             }
          }
       }

Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/PluginMetadata.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -32,6 +32,7 @@
  */
 public class PluginMetadata
 {
+   private String help;
    private String name;
    private Class<? extends Plugin> type;
    private List<CommandMetadata> commands = new ArrayList<CommandMetadata>();
@@ -109,4 +110,14 @@
    {
       return "PluginMetadata [name=" + name + ", type=" + type + ", commands=" + commands + "]";
    }
+
+   public String getHelp()
+   {
+      return help;
+   }
+
+   public void setHelp(final String help)
+   {
+      this.help = help;
+   }
 }

Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Echo.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -26,15 +26,14 @@
 import org.jboss.encore.shell.Shell;
 import org.jboss.encore.shell.plugins.Command;
 import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
 import org.jboss.encore.shell.plugins.Option;
 import org.jboss.encore.shell.plugins.Plugin;
 
 /**
- * Implements a demonstration {@link Plugin}
- * 
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- * 
  */
+ at Help("Writes input to output.")
 public class Echo implements Plugin
 {
    @Inject

Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/ExitShell.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -28,23 +28,24 @@
 import org.jboss.encore.shell.events.Shutdown;
 import org.jboss.encore.shell.plugins.Command;
 import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
 import org.jboss.encore.shell.plugins.Plugin;
 
 /**
- * Implements a {@link Plugin} that fires the shell {@link Shutdown#NORMAL}
- * event.
+ * Implements a {@link Plugin} that fires the shell {@link Shutdown#NORMAL} event.
  * 
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
  * 
  */
 @Named("exit")
+ at Help("Exits the shell.")
 public class ExitShell implements Plugin
 {
    @Inject
    private Event<Shutdown> shutdown;
 
    @Default
-   @Command(help = "Exit the shell")
+   @Command
    public void exit()
    {
       shutdown.fire(Shutdown.NORMAL);

Deleted: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.encore.shell.cli.builtin;
-
-import java.util.Arrays;
-
-import org.jboss.encore.shell.events.Shutdown;
-import org.jboss.encore.shell.plugins.Command;
-import org.jboss.encore.shell.plugins.Default;
-import org.jboss.encore.shell.plugins.Option;
-import org.jboss.encore.shell.plugins.Plugin;
-
-/**
- * Implements a {@link Plugin} that fires the shell {@link Shutdown#NORMAL}
- * event.
- * 
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- * 
- */
-public class Help implements Plugin
-{
-   @Default
-   @Command(help = "Get help about specific commands")
-   public void help(@Option("test") final String test, @Option final String... commands)
-   {
-      if (commands == null)
-      {
-         System.out.println("Welcome to Encore!");
-      }
-      else
-      {
-         System.out.println("You requested help for: " + Arrays.deepToString(commands));
-      }
-   }
-}

Copied: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java (from rev 13389, sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/Help.java)
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java	                        (rev 0)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/cli/builtin/HelpPlugin.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.encore.shell.cli.builtin;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jboss.encore.shell.Shell;
+import org.jboss.encore.shell.cli.PluginRegistry;
+import org.jboss.encore.shell.plugins.Command;
+import org.jboss.encore.shell.plugins.Default;
+import org.jboss.encore.shell.plugins.Help;
+import org.jboss.encore.shell.plugins.Option;
+import org.jboss.encore.shell.plugins.Plugin;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+ at Named("help")
+ at Help("Displays help text for specified plugins & commands.")
+public class HelpPlugin implements Plugin
+{
+   @Inject
+   PluginRegistry registry;
+
+   @Inject
+   Shell shell;
+
+   @Default
+   @Command(help = "Get help about specific commands")
+   public void help(@Option("test") final String test, @Option final String... commands)
+   {
+      if (commands == null)
+      {
+         shell.write("Welcome to Encore!");
+      }
+      else
+      {
+         shell.write("[" + commands[0] + "] " + registry.getPlugins().get(commands[0]).getHelp());
+      }
+   }
+}

Modified: sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java
===================================================================
--- sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java	2010-07-14 21:11:09 UTC (rev 13392)
+++ sandbox/encore/shell/src/main/java/org/jboss/encore/shell/plugins/Option.java	2010-07-14 22:36:54 UTC (rev 13393)
@@ -44,7 +44,7 @@
 public @interface Option
 {
    /**
-    * The name of this option;
+    * The name of this option.
     */
    String value() default "";
 



More information about the seam-commits mailing list