Author: jdillon
Date: Fri Oct 17 01:13:43 2008
New Revision: 705504
URL: http://svn.apache.org/viewvc?rev=705504&view=rev
Log:
Use custom terminal instances to fix some turds, remove the settings muck from cli
Added:
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/AutoDetectedTerminal.java
(with props)
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnixTerminal.java
(with props)
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnsupportedTerminal.java
(with props)
geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/WindowsTerminal.java
(with props)
Modified:
geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties
Modified: geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=705504&r1=705503&r2=705504&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Fri Oct 17 01:13:43 2008
@@ -21,7 +21,6 @@
import org.apache.geronimo.gshell.ansi.ANSI;
import org.apache.geronimo.gshell.application.ApplicationModelLocator;
-import org.apache.geronimo.gshell.application.settings.SettingsModelLocator;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.CommandLineProcessor;
import org.apache.geronimo.gshell.clp.Option;
@@ -30,11 +29,14 @@
import org.apache.geronimo.gshell.i18n.ResourceBundleMessageSource;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.model.application.ApplicationModel;
-import org.apache.geronimo.gshell.model.settings.SettingsModel;
import org.apache.geronimo.gshell.notification.ExitNotification;
import org.apache.geronimo.gshell.shell.Shell;
import org.apache.geronimo.gshell.wisdom.builder.ShellBuilder;
import org.apache.geronimo.gshell.wisdom.builder.ShellBuilderImpl;
+import org.apache.geronimo.gshell.terminal.UnixTerminal;
+import org.apache.geronimo.gshell.terminal.WindowsTerminal;
+import org.apache.geronimo.gshell.terminal.UnsupportedTerminal;
+import org.apache.geronimo.gshell.terminal.AutoDetectedTerminal;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@@ -81,11 +83,8 @@
/*
@Option(name="-a", aliases={"--application"})
private String applicationDescriptor;
-
- @Option(name="-s", aliases={"--settings"})
- private String settingsDescriptor;
*/
-
+
@Option(name="-e", aliases={"--exception"})
private void setException(boolean flag) {
if (flag) {
@@ -160,35 +159,24 @@
private void setTerminalType(String type) {
type = type.toLowerCase();
- //
- // FIXME: Provide an abstraction over the jline term stuff and its warts, and/or
fork it and re-implement it to not be so broken
- //
-
if ("unix".equals(type)) {
- type = "jline.UnixTerminal";
+ type = UnixTerminal.class.getName();
}
else if ("win".equals(type) || "windows".equals("type")) {
- type = "jline.WindowsTerminal";
+ type = WindowsTerminal.class.getName();
}
else if ("false".equals(type) || "off".equals(type) || "none".equals(type)) {
- type = "jline.UnsupportedTerminal";
-
- //
- // HACK: Disable ANSI, for some reason UnsupportedTerminal reports ANSI as enabled,
when it shouldn't
- // as a temporary solution, could provide a Terminal instance which can
delegate and fix warts like this
- //
- ANSI.setEnabled(false);
+ type = UnsupportedTerminal.class.getName();
}
System.setProperty("jline.terminal", type);
}
- @Option(name="-o", aliases="--offline")
- private boolean offline;
-
public void boot(final String[] args) throws Exception {
assert args != null;
+ System.setProperty("jline.terminal", AutoDetectedTerminal.class.getName());
+
// Default is to be quiet
setConsoleLogLevel("WARN");
@@ -221,12 +209,6 @@
builder.setClassLoader(getClass().getClassLoader());
builder.setIo(io);
- // Find our settings descriptor
- SettingsModel settingsModel = new SettingsModelLocator().
- /*addLocation(settingsDescriptor).*/locate();
- settingsModel.setOnline(!offline);
- builder.setSettingsModel(settingsModel);
-
// Find our application descriptor
ApplicationModel applicationModel = new ApplicationModelLocator().
/*addLocation(applicationDescriptor).*/locate();
Modified: geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties?rev=705504&r1=705503&r2=705504&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties
(original)
+++ geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties
Fri Oct 17 01:13:43 2008
@@ -57,6 +57,4 @@
option.setTerminalType=Specify the terminal TYPE to use
option.setTerminalType.token=TYPE
-option.offline=For artifact resolution to be offline
-
warning.abnormalShutdown=WARNING: Abnormal JVM shutdown detected
\ No newline at end of file
Added: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/AutoDetectedTerminal.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/AutoDetectedTerminal.java?rev=705504&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/AutoDetectedTerminal.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/AutoDetectedTerminal.java
Fri Oct 17 01:13:43 2008
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.terminal;
+
+import jline.Terminal;
+import jline.ConsoleReader;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * Auto-detected terminal.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AutoDetectedTerminal
+ extends jline.Terminal
+{
+ private final Terminal terminal;
+
+ public AutoDetectedTerminal() {
+ String os = System.getProperty("os.name").toLowerCase();
+
+ if (os.indexOf("windows") != -1) {
+ terminal = new jline.WindowsTerminal();
+ }
+ else {
+ terminal = new UnixTerminal();
+ }
+ }
+
+ public boolean isANSISupported() {
+ return terminal.isANSISupported();
+ }
+
+ public int readCharacter(InputStream in) throws IOException {
+ return terminal.readCharacter(in);
+ }
+
+ public int readVirtualKey(InputStream in) throws IOException {
+ return terminal.readVirtualKey(in);
+ }
+
+ public void initializeTerminal() throws Exception {
+ terminal.initializeTerminal();
+ }
+
+ public int getTerminalWidth() {
+ return terminal.getTerminalWidth();
+ }
+
+ public int getTerminalHeight() {
+ return terminal.getTerminalHeight();
+ }
+
+ public boolean isSupported() {
+ return terminal.isSupported();
+ }
+
+ public boolean getEcho() {
+ return terminal.getEcho();
+ }
+
+ public void beforeReadLine(ConsoleReader reader, String prompt, Character mask) {
+ terminal.beforeReadLine(reader, prompt, mask);
+ }
+
+ public void afterReadLine(ConsoleReader reader, String prompt, Character mask) {
+ terminal.afterReadLine(reader, prompt, mask);
+ }
+
+ public boolean isEchoEnabled() {
+ return terminal.isEchoEnabled();
+ }
+
+ public void enableEcho() {
+ terminal.enableEcho();
+ }
+
+ public void disableEcho() {
+ terminal.disableEcho();
+ }
+
+ public InputStream getDefaultBindings() {
+ return terminal.getDefaultBindings();
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/AutoDetectedTerminal.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/AutoDetectedTerminal.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/AutoDetectedTerminal.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnixTerminal.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnixTerminal.java?rev=705504&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnixTerminal.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnixTerminal.java
Fri Oct 17 01:13:43 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.terminal;
+
+/**
+ * Unix terminal.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnixTerminal
+ extends jline.UnixTerminal
+{
+ @Override
+ public int getTerminalWidth() {
+ int width = super.getTerminalWidth();
+ if (width < 1) {
+ width = 80;
+ }
+ return width;
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnixTerminal.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnixTerminal.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnixTerminal.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnsupportedTerminal.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnsupportedTerminal.java?rev=705504&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnsupportedTerminal.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnsupportedTerminal.java
Fri Oct 17 01:13:43 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.terminal;
+
+/**
+ * Unsupported terminal.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnsupportedTerminal
+ extends jline.UnsupportedTerminal
+{
+ @Override
+ public boolean isANSISupported() {
+ return false;
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnsupportedTerminal.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnsupportedTerminal.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/UnsupportedTerminal.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/WindowsTerminal.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/WindowsTerminal.java?rev=705504&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/WindowsTerminal.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/WindowsTerminal.java
Fri Oct 17 01:13:43 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.terminal;
+
+/**
+ * Windows terminal.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WindowsTerminal
+ extends jline.WindowsTerminal
+{
+ @Override
+ public int getTerminalWidth() {
+ int width = super.getTerminalWidth();
+ if (width < 1) {
+ width = 80;
+ }
+ return width;
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/WindowsTerminal.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/WindowsTerminal.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-terminal/src/main/java/org/apache/geronimo/gshell/terminal/WindowsTerminal.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
|