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/09/15 08:29:59 UTC
svn commit: r695353 - in /geronimo/gshell/trunk/gshell-cli: ./
src/main/java/org/apache/geronimo/gshell/cli/ src/main/resources/
src/main/resources/org/ src/main/resources/org/apache/
src/main/resources/org/apache/geronimo/ src/main/resources/org/apach...
Author: jdillon
Date: Sun Sep 14 23:29:56 2008
New Revision: 695353
URL: http://svn.apache.org/viewvc?rev=695353&view=rev
Log:
Use i18n messages for Main
Added:
geronimo/gshell/trunk/gshell-cli/src/main/resources/
geronimo/gshell/trunk/gshell-cli/src/main/resources/org/
geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/
geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/
geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/
geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/
geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties (with props)
Modified:
geronimo/gshell/trunk/gshell-cli/pom.xml
geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Modified: geronimo/gshell/trunk/gshell-cli/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-cli/pom.xml?rev=695353&r1=695352&r2=695353&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-cli/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-cli/pom.xml Sun Sep 14 23:29:56 2008
@@ -50,6 +50,11 @@
<dependency>
<groupId>org.apache.geronimo.gshell.support</groupId>
+ <artifactId>gshell-i18n</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.gshell.support</groupId>
<artifactId>gshell-io</artifactId>
</dependency>
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=695353&r1=695352&r2=695353&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 Sun Sep 14 23:29:56 2008
@@ -19,22 +19,23 @@
package org.apache.geronimo.gshell.cli;
-import org.apache.geronimo.gshell.notification.ExitNotification;
-import org.apache.geronimo.gshell.shell.Shell;
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;
import org.apache.geronimo.gshell.clp.Printer;
+import org.apache.geronimo.gshell.i18n.MessageSource;
+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.application.settings.SettingsModelLocator;
+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 java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@@ -53,32 +54,34 @@
private final IO io = new IO();
+ private final MessageSource messages = new ResourceBundleMessageSource(this.getClass());
+
//
// TODO: Add flag to capture output to log file
// https://issues.apache.org/jira/browse/GSHELL-47
//
- @Option(name="-h", aliases={"--help"}, requireOverride=true, description="Display this help message")
+ @Option(name="-h", aliases={"--help"}, requireOverride=true)
private boolean help;
- @Option(name="-V", aliases={"--version"}, requireOverride=true, description="Display program version")
+ @Option(name="-V", aliases={"--version"}, requireOverride=true)
private boolean version;
- @Option(name="-i", aliases={"--interactive"}, description="Run in interactive mode")
+ @Option(name="-i", aliases={"--interactive"})
private boolean interactive = true;
private void setConsoleLogLevel(final String level) {
System.setProperty("gshell.log.console.level", level);
}
- @Option(name="-e", aliases={"--exception"}, description="Enable exception stack traces")
+ @Option(name="-e", aliases={"--exception"})
private void setException(boolean flag) {
if (flag) {
System.setProperty("gshell.show.stacktrace","true");
}
}
- @Option(name="-d", aliases={"--debug"}, description="Enable DEBUG output")
+ @Option(name="-d", aliases={"--debug"})
private void setDebug(boolean flag) {
if (flag) {
setConsoleLogLevel("DEBUG");
@@ -86,7 +89,7 @@
}
}
- @Option(name="-X", aliases={"--trace"}, description="Enable TRACE output")
+ @Option(name="-X", aliases={"--trace"})
private void setTrace(boolean flag) {
if (flag) {
setConsoleLogLevel("TRACE");
@@ -94,7 +97,7 @@
}
}
- @Option(name="-v", aliases={"--verbose"}, description="Enable INFO output")
+ @Option(name="-v", aliases={"--verbose"})
private void setVerbose(boolean flag) {
if (flag) {
setConsoleLogLevel("INFO");
@@ -102,7 +105,7 @@
}
}
- @Option(name="-q", aliases={"--quiet"}, description="Limit output to ERROR")
+ @Option(name="-q", aliases={"--quiet"})
private void setQuiet(boolean flag) {
if (flag) {
setConsoleLogLevel("ERROR");
@@ -110,14 +113,13 @@
}
}
- @Option(name="-c", aliases={"--commands"}, description="Read commands from string")
+ @Option(name="-c", aliases={"--commands"}, metaVar="STRING")
private String commands;
- @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
- @Argument(description="Command")
- private List<String> commandArgs = new ArrayList<String>(0);
+ @Argument(metaVar="COMMAND")
+ private List<String> commandArgs = null;
- @Option(name="-D", aliases={"--define"}, metaVar="NAME=VALUE", description="Define system properties")
+ @Option(name="-D", aliases={"--define"}, metaVar="NAME=VALUE")
private void setSystemProperty(final String nameValue) {
assert nameValue != null;
@@ -137,12 +139,12 @@
System.setProperty(name, value);
}
- @Option(name="-C", aliases={"--color"}, argumentRequired=true, description="Enable or disable use of ANSI colors")
+ @Option(name="-C", aliases={"--color"}, argumentRequired=true)
private void enableAnsiColors(final boolean flag) {
ANSI.setEnabled(flag);
}
- @Option(name="-T", aliases={"--terminal"}, metaVar="TYPE", argumentRequired=true, description="Specify the terminal TYPE to use")
+ @Option(name="-T", aliases={"--terminal"}, metaVar="TYPE", argumentRequired=true)
private void setTerminalType(String type) {
type = type.toLowerCase();
@@ -186,7 +188,7 @@
if (!io.isSilent()) {
io.err.println();
- io.err.println("WARNING: Abnormal JVM shutdown detected");
+ io.err.println(messages.getMessage("warning.abnormalShutdown"));
}
}
@@ -213,17 +215,18 @@
if (help|version) {
if (help) {
- io.out.println(applicationModel.getBranding().getProgramName() + " [options] <command> [args]");
+ io.out.println(applicationModel.getBranding().getProgramName() + " [options] <command> [arguments]");
io.out.println();
Printer printer = new Printer(clp);
+ printer.setMessageSource(messages);
printer.printUsage(io.out);
}
else if (version) {
io.out.println(applicationModel.getVersion());
+ io.out.println();
}
- io.out.println();
io.out.flush();
throw new ExitNotification();
@@ -233,7 +236,10 @@
Shell gshell = builder.create();
// clp gives us a list, but we need an array
- String[] _args = commandArgs.toArray(new String[commandArgs.size()]);
+ String[] _args = {};
+ if (commandArgs != null) {
+ commandArgs.toArray(new String[commandArgs.size()]);
+ }
if (commands != null) {
gshell.execute(commands);
Added: 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=695353&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties (added)
+++ geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties Sun Sep 14 23:29:56 2008
@@ -0,0 +1,50 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+option.help=Display this help message
+
+option.version=Display program version
+
+option.interactive=Run in interactive mode
+
+option.setException=Enable exception stack traces
+
+option.setDebug=Enable DEBUG output
+
+option.setTrace=Enable TRACE output
+
+option.setVerbose=Enable INFO output
+
+option.setQuiet=Limit output to ERROR
+
+option.commands=Parse command line from STRING
+
+argument.commandArgs=Command expression to execute
+
+option.setSystemProperty=Define system properties
+
+option.enableAnsiColors=Enable or disable use of ANSI colors
+
+option.setTerminalType=Specify the terminal TYPE to use
+
+warning.abnormalShutdown=WARNING: Abnormal JVM shutdown detected
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/Main.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain