Skip to content

Commit

Permalink
Refactored the logic into the ShellImpl class
Browse files Browse the repository at this point in the history
  • Loading branch information
VineetReynolds committed Feb 6, 2014
1 parent cfe09a4 commit 8475299
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
import javax.inject.Inject;

import org.jboss.aesh.console.settings.Settings;
import org.jboss.aesh.console.settings.SettingsBuilder;
import org.jboss.forge.addon.resource.FileResource;
import org.jboss.forge.addon.resource.ResourceFactory;
import org.jboss.forge.addon.ui.controller.CommandControllerFactory;
import org.jboss.forge.furnace.addons.AddonRegistry;
import org.jboss.forge.furnace.util.Assert;
import org.jboss.forge.furnace.util.OperatingSystemUtils;

/**
* Creates {@link Shell} instances
Expand Down Expand Up @@ -50,16 +48,7 @@ public Shell createShell(File initialSelection, Settings settings)
{
Assert.notNull(settings, "Settings cannot be null");
FileResource<?> initialResource = resourceFactory.create(initialSelection).reify(FileResource.class);
File forgeHome = OperatingSystemUtils.getUserForgeDir();
File history = new File(forgeHome, "history");
File alias = new File(forgeHome, "alias");
File export = new File(forgeHome, "export");
Settings newSettings = new SettingsBuilder(settings)
.historyFile(history)
.aliasFile(alias)
.setExportFile(export)
.create();
return new ShellImpl(initialResource, newSettings, commandManager, addonRegistry, commandFactory);
return new ShellImpl(initialResource, settings, commandManager, addonRegistry, commandFactory);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.jboss.forge.addon.shell;

import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -69,15 +70,24 @@ public ShellImpl(FileResource<?> initialResource, Settings settings,
{
this.currentResource = initialResource;
this.addonRegistry = addonRegistry;
Settings newSettings = new SettingsBuilder(settings).interruptHook(new InterruptHook()
{
@Override
public void handleInterrupt(Console console)
{
console.getShell().out().println("^C");
console.clearBufferAndDisplayPrompt();
}
}).create();
// Set the paths for the Aesh history, alias and export files.
File forgeHome = OperatingSystemUtils.getUserForgeDir();
File history = new File(forgeHome, "history");
File alias = new File(forgeHome, "alias");
File export = new File(forgeHome, "export");
Settings newSettings = new SettingsBuilder(settings)
.historyFile(history)
.aliasFile(alias)
.exportFile(export)
.interruptHook(new InterruptHook()
{
@Override
public void handleInterrupt(Console console)
{
console.getShell().out().println("^C");
console.clearBufferAndDisplayPrompt();
}
}).create();
final ForgeCommandRegistry registry = new ForgeCommandRegistry(this, commandManager, commandFactory,
commandManager
.getConverterFactory());
Expand Down

0 comments on commit 8475299

Please sign in to comment.