You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/12/13 08:14:09 UTC
svn commit: r726177 -
/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ConsolePrompterImpl.java
Author: jdillon
Date: Fri Dec 12 23:14:09 2008
New Revision: 726177
URL: http://svn.apache.org/viewvc?rev=726177&view=rev
Log:
Use ShellContextHolder to get variables
Modified:
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ConsolePrompterImpl.java
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ConsolePrompterImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ConsolePrompterImpl.java?rev=726177&r1=726176&r2=726177&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ConsolePrompterImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ConsolePrompterImpl.java Fri Dec 12 23:14:09 2008
@@ -24,6 +24,7 @@
import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.console.Console;
import org.apache.geronimo.gshell.interpolation.VariablesValueSource;
+import org.apache.geronimo.gshell.shell.ShellContextHolder;
import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.Interpolator;
import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
@@ -41,33 +42,29 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- private final Application application;
-
private final Interpolator interp = new StringSearchInterpolator("%{", "}");
private final VariablesValueSource variablesValueSource = new VariablesValueSource();
private final AnsiRenderer renderer = new AnsiRenderer();
- public ConsolePrompterImpl(final Application application) {
- assert application != null;
- this.application = application;
- }
+ private final String defaultPrompt;
- // @PostConstruct
- public void init() {
+ public ConsolePrompterImpl(final Application application) {
assert application != null;
+
interp.addValueSource(new PrefixedObjectValueSource("application", application));
interp.addValueSource(new PrefixedObjectValueSource("branding", application.getModel().getBranding()));
interp.addValueSource(variablesValueSource);
+
+ defaultPrompt = application.getModel().getBranding().getPrompt();
}
public String prompt() {
String prompt = null;
- assert application != null;
- Variables vars = application.getVariables();
- String pattern = (String) vars.get("gshell.prompt");
+ Variables vars = ShellContextHolder.get().getVariables();
+ String pattern = vars.get("gshell.prompt", String.class);
if (pattern != null) {
assert variablesValueSource != null;
@@ -84,7 +81,7 @@
// Use a default prompt if we don't have anything here
if (prompt == null) {
- prompt = defaultPrompt();
+ prompt = defaultPrompt;
}
// Encode ANSI muck if it looks like there are codes encoded
@@ -94,9 +91,4 @@
return prompt;
}
-
- private String defaultPrompt() {
- assert application != null;
- return application.getModel().getBranding().getName() + "> ";
- }
}
\ No newline at end of file