groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [1/2] groovy git commit: GROOVY-8353: groovyConsole should support -Dname=value setting of system properties
Date Thu, 12 Oct 2017 08:21:37 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 617eeba26 -> ff5d63f91


GROOVY-8353: groovyConsole should support -Dname=value setting of system properties


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/03935c98
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/03935c98
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/03935c98

Branch: refs/heads/GROOVY_2_5_X
Commit: 03935c98b825df75da7b8a7f36f0dddb5e2c150b
Parents: 617eeba
Author: paulk <paulk@asert.com.au>
Authored: Thu Oct 12 18:18:36 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Thu Oct 12 18:21:25 2017 +1000

----------------------------------------------------------------------
 .../src/main/groovy/groovy/ui/Console.groovy    | 21 ++++++++++----------
 .../main/resources/groovy/ui/Console.properties |  2 ++
 2 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/03935c98/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
index 4bfb2d4..7663719 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
@@ -67,15 +67,6 @@ import javax.swing.event.DocumentListener
  * Groovy Swing console.
  *
  * Allows user to interactively enter and execute Groovy.
- *
- * @author Danno Ferrin
- * @author Dierk Koenig, changed Layout, included Selection sensitivity, included ObjectBrowser
- * @author Alan Green more features: history, System.out capture, bind result to _
- * @author Guillaume Laforge, stacktrace hyperlinking to the current script line
- * @author Hamlet D'Arcy, AST browser
- * @author Roshan Dawrani
- * @author Paul King
- * @author Andre Steingress
  */
 class Console implements CaretListener, HyperlinkListener, ComponentListener, FocusListener
{
 
@@ -212,6 +203,7 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
             V(longOpt: 'version', messages['cli.option.version.description'])
             pa(longOpt: 'parameters', messages['cli.option.parameters.description'])
             i(longOpt: 'indy', messages['cli.option.indy.description'])
+            D(longOpt: 'define', args: 2, argName: 'name=value', valueSeparator: '=', messages['cli.option.define.description'])
         }
         OptionAccessor options = cli.parse(args)
 
@@ -230,6 +222,12 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
             System.exit(0)
         }
 
+        if (options.hasOption('D')) {
+            options.getOptionProperties('D')?.each { k, v ->
+                System.setProperty(k, v)
+            }
+        }
+
         // full stack trace should not be logged to the output window - GROOVY-4663
         java.util.logging.Logger.getLogger(StackTraceUtils.STACK_LOG_NAME).useParentHandlers
= false
 
@@ -246,8 +244,9 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
         def console = new Console(Console.class.classLoader?.getRootLoader(), new Binding(),
baseConfig)
         console.useScriptClassLoaderForScriptExecution = true
         console.run()
-        if (args.length > 0 && !args[-1].toString().startsWith("-")) {
-            console.loadScriptFile(args[-1] as File)
+        def remaining = options.arguments()
+        if (remaining && !remaining[-1].startsWith("-")) {
+            console.loadScriptFile(remaining[-1] as File)
         }
 
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/03935c98/subprojects/groovy-console/src/main/resources/groovy/ui/Console.properties
----------------------------------------------------------------------
diff --git a/subprojects/groovy-console/src/main/resources/groovy/ui/Console.properties b/subprojects/groovy-console/src/main/resources/groovy/ui/Console.properties
index b04c0ec..3e1436b 100644
--- a/subprojects/groovy-console/src/main/resources/groovy/ui/Console.properties
+++ b/subprojects/groovy-console/src/main/resources/groovy/ui/Console.properties
@@ -28,6 +28,8 @@ cli.option.parameters.description=Generate metadata for reflection on method
par
 
 cli.option.indy.description=Enable InvokeDynamic (Indy) compilation for scripts
 
+cli.option.define.description=Define a system property
+
 cli.info.version=GroovyConsole {0}
 
 # Preferences Dialog


Mime
View raw message