Skip to content

Commit

Permalink
FORGE-747
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jan 15, 2013
1 parent 0fb4a08 commit 9794cf5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public static List<PluginEntry> listByAPICompatibleVersion(final String version)
public static List<PluginEntry> list()
{
List<PluginEntry> result = new ArrayList<PluginEntry>();
// File registryFile = new File(OSUtils.getUserHomePath() + getRegistry());
File registryFile = getRegistryFile();
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,15 @@ public void restart() throws Exception
}

@Command(value = "list-plugins", help = "List all installed plugin JAR files.")
public void listInstalled(
@Option(name = "all",
shortName = "a",
description = "Show extra information about each installed plugin",
defaultValue = "false") final boolean showAll)
{
DirectoryResource pluginDir = environment.getPluginDirectory();

displayModules(pluginDir);
}

private void displayModules(final DirectoryResource pluginDir)
public void listInstalled(PipeOut out, String input)
{
List<PluginEntry> plugins = InstalledPluginRegistry.list();
for (PluginEntry plugin : plugins)
{
writer.println(plugin.toString());
if (Strings.isNullOrEmpty(input) || plugin.toString().contains(input))
{
out.println(plugin.toString());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
package org.jboss.forge.shell.test.plugins.builtin;

import org.jboss.arquillian.junit.Arquillian;
import org.jboss.forge.shell.InstalledPluginRegistry;
import org.jboss.forge.shell.Shell;
import org.jboss.forge.shell.ShellImpl;
import org.jboss.forge.test.AbstractShellTest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
Expand Down Expand Up @@ -57,4 +59,26 @@ public void testBuildPrettyfaces() throws Exception
getShell().execute("forge install-plugin ocpsoft-prettyfaces");
}

@Test
public void testListPlugins() throws Exception
{
InstalledPluginRegistry.install("test.test", "1.0.0-SNAPSHOT", "moo");
getShell().execute("forge list-plugins arquillian");
Assert.assertFalse(getOutput().contains("test.test"));

getShell().execute("forge list-plugins test.test");
Assert.assertTrue(getOutput().contains("test.test"));
}

@Test
public void testListPluginsGrep() throws Exception
{
InstalledPluginRegistry.install("test.test", "1.0.0-SNAPSHOT", "moo");
getShell().execute("forge list-plugins | grep arquillian");
Assert.assertFalse(getOutput().contains("test.test"));

getShell().execute("forge list-plugins | grep test.test");
Assert.assertTrue(getOutput().contains("test.test"));
}

}

0 comments on commit 9794cf5

Please sign in to comment.