Skip to content

Commit

Permalink
Revert "update aesh dependency to 0.39"
Browse files Browse the repository at this point in the history
This reverts commit 020e656.
  • Loading branch information
lincolnthree committed Jul 30, 2013
1 parent cb0cd66 commit e45ac60
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.jboss.forge.addon.resource.DirectoryResource;
import org.jboss.forge.addon.resource.ResourceFactory;
import org.jboss.forge.addon.shell.ForgeShell;
import org.jboss.forge.addon.shell.test.TestSettingsProvider;
import org.jboss.forge.addon.shell.test.TestShellConfiguration;
import org.jboss.forge.arquillian.AddonDependency;
import org.jboss.forge.arquillian.Dependencies;
import org.jboss.forge.arquillian.archive.ForgeArchive;
Expand Down Expand Up @@ -61,7 +61,7 @@ public static ForgeArchive getDeployment()
private ForgeShell shell;

@Inject
private TestSettingsProvider streams;
private TestShellConfiguration streams;

@Inject
private ProjectFactory projectFactory;
Expand Down Expand Up @@ -96,7 +96,7 @@ public void testContainerInjection() throws Exception
Project project = projectFactory.findProject(projectRoot.getChildDirectory("lincoln"));

Assert.assertNotNull(project);

Assert.assertTrue(project.getProjectRoot().exists());

// TODO Wizard steps are not implemented by Aesh, so we can't actually invoke the entire wizard.
Expand Down
1 change: 1 addition & 0 deletions shell/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<artifactId>container-cdi-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.forge.addon</groupId>
<artifactId>shell-spi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
import org.jboss.aesh.console.ConsoleOutput;
import org.jboss.aesh.console.Prompt;
import org.jboss.aesh.console.settings.Settings;
import org.jboss.aesh.console.settings.SettingsBuilder;
import org.jboss.aesh.terminal.CharacterType;
import org.jboss.aesh.terminal.Color;
import org.jboss.aesh.terminal.TerminalCharacter;
import org.jboss.forge.addon.shell.spi.AeshSettingsProvider;
import org.jboss.forge.addon.shell.spi.CommandExecutionListener;
import org.jboss.forge.addon.shell.spi.ShellConfiguration;
import org.jboss.forge.addon.shell.util.CommandLineUtil;
import org.jboss.forge.addon.shell.util.UICommandDelegate;
import org.jboss.forge.addon.ui.UICommand;
Expand All @@ -62,7 +61,6 @@ public class ForgeShellImpl implements ForgeShell
private static final Logger logger = Logger.getLogger(ForgeShellImpl.class.getName());

private Console console;
private Settings settings;
private Prompt prompt;
private List<ShellCommand> wizardSteps = new ArrayList<ShellCommand>();

Expand Down Expand Up @@ -96,6 +94,7 @@ public void stopShell() throws IOException
if (console != null && console.isRunning())
{
console.stop();
console.reset();
}
}

Expand All @@ -109,21 +108,17 @@ private void initShell() throws Exception
{
prompt = createPrompt();

for (ExportedInstance<AeshSettingsProvider> instance : registry.getExportedInstances(AeshSettingsProvider.class))
Settings.getInstance().setReadInputrc(false);
Settings.getInstance().setLogging(true);

for (ExportedInstance<ShellConfiguration> instance : registry.getExportedInstances(ShellConfiguration.class))
{
AeshSettingsProvider provider = instance.get();
settings = provider.buildSettings();
}

if (settings == null) {
settings = new SettingsBuilder()
.readInputrc(false)
.logging(true)
.create();
ShellConfiguration provider = instance.get();
provider.configure();
}

commands = new ArrayList<ShellCommand>();
console = new Console(settings);
console = Console.getInstance();
console.setPrompt(prompt);
console.setConsoleCallback(new ForgeConsoleCallback());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public boolean isStandalone()
public void complete(CompleteOperation completeOperation)
{
try {
ParameterInt param = context.getParser().getParameter();
ParameterInt param = context.getParser().getParameters().get(0);
// complete command names
if (param.getName().startsWith(completeOperation.getBuffer()))
completeOperation.addCompletionCandidate(param.getName());
Expand Down Expand Up @@ -186,7 +186,7 @@ private void defaultCompletion(CompleteOperation completeOperation) throws Comma
.findCompleteObject(completeOperation.getBuffer()));
}
else {
completeOperation.addCompletionCandidates(context.getParser().getParameter().getOptionLongNamesWithDash());
completeOperation.addCompletionCandidates(context.getParser().getParameters().get(0).getOptionLongNamesWithDash());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static CommandLineParser generateParser(UICommand command, ShellContext c
}
}
}
builder.parameter(parameter);
builder.addParameter(parameter);
return builder.generateParser();
}

Expand Down
2 changes: 1 addition & 1 deletion shell/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</modules>

<properties>
<version.aesh>0.39</version.aesh>
<version.aesh>0.38</version.aesh>
<version.aesh.extensions>0.38</version.aesh.extensions>
</properties>

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.jboss.aesh.console.settings.Settings;
Expand All @@ -32,41 +31,41 @@ public class TestShellConfiguration implements ShellConfiguration
private ByteArrayOutputStream stdout = new ByteArrayOutputStream();
private ByteArrayOutputStream stderr = new ByteArrayOutputStream();
PipedInputStream inputStream;

@Override
public synchronized void configure()
{
// try
// {
// Settings settings = Settings.getInstance();
//
// inputStream = new PipedInputStream(stdin);
// settings.setInputStream(inputStream);
// settings.setStdOut(stdout);
// settings.setStdErr(stderr);
// settings.setName("test");
// settings.setLogging(true);
// settings.setTerminal(new TestTerminal());
// settings.getOperationManager().addOperation(new KeyOperation(Key.ENTER, Operation.NEW_LINE));
// }
// catch (IOException e)
// {
// throw new RuntimeException("Could not configure Shell.", e);
// }
try
{
Settings settings = Settings.getInstance();

inputStream = new PipedInputStream(stdin);
settings.setInputStream(inputStream);
settings.setStdOut(stdout);
settings.setStdErr(stderr);
settings.setName("test");
settings.setLogging(true);
settings.setTerminal(new TestTerminal());
settings.getOperationManager().addOperation(new KeyOperation(Key.ENTER, Operation.NEW_LINE));
}
catch (IOException e)
{
throw new RuntimeException("Could not configure Shell.", e);
}
}

public synchronized OutputStream getStdIn()
{
return stdin;
}

// public synchronized OutputStream getStdIn()
// {
// return stdin;
// }
//
// public synchronized ByteArrayOutputStream getStdOut()
// {
// return stdout;
// }
//
// public synchronized ByteArrayOutputStream getStdErr()
// {
// return stderr;
// }
public synchronized ByteArrayOutputStream getStdOut()
{
return stdout;
}

public synchronized ByteArrayOutputStream getStdErr()
{
return stderr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
@Singleton
public class ShellTestImpl implements ShellTest
{
// private TestShellConfiguration config;
private TestShellConfiguration config;
private TestCommandListener listener;
private TestSettingsProvider provider;

@Inject
public ShellTestImpl(TestSettingsProvider provider, TestCommandListener listener)
public ShellTestImpl(TestShellConfiguration config, TestCommandListener listener)
{
this.listener = listener;
this.provider = provider;
this.config = config;
}

@Override
Expand All @@ -47,7 +46,7 @@ public Result execute(String line)
if (!line.trim().endsWith("\n"))
line = line + "\n";
listener.reset();
provider.getStdIn().write(line.getBytes());
config.getStdIn().write(line.getBytes());
while (!listener.isExecuted())
{
Thread.sleep(10);
Expand All @@ -72,7 +71,7 @@ public Result execute(String line, int quantity, TimeUnit unit)
if (!line.trim().endsWith("\n"))
line = line + "\n";
listener.reset();
provider.getStdIn().write(line.getBytes());
config.getStdIn().write(line.getBytes());
long start = System.currentTimeMillis();
while (!listener.isExecuted())
{
Expand Down Expand Up @@ -102,13 +101,13 @@ public Result execute(String line, int quantity, TimeUnit unit)
@Override
public void waitForStdOut(String value, int quantity, TimeUnit unit) throws TimeoutException
{
waitForStream(value, provider.getStdOut(), quantity, unit);
waitForStream(value, config.getStdOut(), quantity, unit);
}

@Override
public void waitForStdErr(String value, int quantity, TimeUnit unit) throws TimeoutException
{
waitForStream(value, provider.getStdErr(), quantity, unit);
waitForStream(value, config.getStdErr(), quantity, unit);
}

private void waitForStream(String value, ByteArrayOutputStream stream, int quantity, TimeUnit unit)
Expand All @@ -117,8 +116,8 @@ private void waitForStream(String value, ByteArrayOutputStream stream, int quant
stream.reset();
try
{
provider.getStdIn().write(value.getBytes());
provider.getStdIn().flush();
config.getStdIn().write(value.getBytes());
config.getStdIn().flush();
}
catch (IOException e)
{
Expand Down Expand Up @@ -147,19 +146,19 @@ private void waitForStream(String value, ByteArrayOutputStream stream, int quant
@Override
public OutputStream getStdIn()
{
return provider.getStdIn();
return config.getStdIn();
}

@Override
public String getStdOut()
{
return provider.getStdOut().toString();
return config.getStdOut().toString();
}

@Override
public String getStdErr()
{
return provider.getStdErr().toString();
return config.getStdErr().toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.forge.addon.shell.test.TestSettingsProvider;
import org.jboss.forge.addon.shell.test.TestShellConfiguration;
import org.jboss.forge.arquillian.AddonDependency;
import org.jboss.forge.arquillian.Dependencies;
import org.jboss.forge.arquillian.archive.ForgeArchive;
Expand Down Expand Up @@ -50,7 +50,7 @@ public static ForgeArchive getDeployment()
private ForgeShell shell;

@Inject
private TestSettingsProvider streams;
private TestShellConfiguration streams;

@Test
public void testCommandExecutionListenerTriggers() throws Exception
Expand Down
Loading

0 comments on commit e45ac60

Please sign in to comment.