You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2022/11/13 04:42:27 UTC

[groovy] branch master updated: GROOVY-8668: add property groovysh.disableDocCommand (#1822)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 40a2809031 GROOVY-8668: add property groovysh.disableDocCommand (#1822)
40a2809031 is described below

commit 40a280903132d5072acbd757d3df792ded808c7d
Author: tison <wa...@gmail.com>
AuthorDate: Sun Nov 13 12:42:19 2022 +0800

    GROOVY-8668: add property groovysh.disableDocCommand (#1822)
    
    * add property groovysh.disableDocCommand
    
    Signed-off-by: tison <wa...@gmail.com>
    
    * null safe operator
    
    Signed-off-by: tison <wa...@gmail.com>
    
    Signed-off-by: tison <wa...@gmail.com>
---
 .../groovysh/util/DefaultCommandsRegistrar.groovy  | 47 +++++++++++-----------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/util/DefaultCommandsRegistrar.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/util/DefaultCommandsRegistrar.groovy
index 3c7d1f0600..9fc9ef430c 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/util/DefaultCommandsRegistrar.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/util/DefaultCommandsRegistrar.groovy
@@ -57,31 +57,32 @@ class DefaultCommandsRegistrar {
     }
 
     void register() {
+        def commands = [
+            new HelpCommand(shell),
+            new ExitCommand(shell),
+            new ImportCommand(shell),
+            new DisplayCommand(shell),
+            new ClearCommand(shell),
+            new ShowCommand(shell),
+            new InspectCommand(shell),
+            new PurgeCommand(shell),
+            new EditCommand(shell),
+            new LoadCommand(shell),
+            new SaveCommand(shell),
+            new RecordCommand(shell),
+            new HistoryCommand(shell),
+            new AliasCommand(shell),
+            new SetCommand(shell),
+            new GrabCommand(shell),
+            new RegisterCommand(shell),
+        ]
 
-        for (Command classname in [
-                new HelpCommand(shell),
-                new ExitCommand(shell),
-                new ImportCommand(shell),
-                new DisplayCommand(shell),
-                new ClearCommand(shell),
-                new ShowCommand(shell),
-                new InspectCommand(shell),
-                new PurgeCommand(shell),
-                new EditCommand(shell),
-                new LoadCommand(shell),
-                new SaveCommand(shell),
-                new RecordCommand(shell),
-                new HistoryCommand(shell),
-                new AliasCommand(shell),
-                new SetCommand(shell),
-                new GrabCommand(shell),
-                // does not do anything
-                //new ShadowCommand(shell),
-                new RegisterCommand(shell),
-                new DocCommand(shell)
-        ]) {
-            shell.register(classname)
+        if (!System.getProperty("groovysh.disableDocCommand")?.toBoolean()) {
+            commands.add(new DocCommand(shell))
         }
 
+        for (Command classname in commands) {
+            shell.register(classname)
+        }
     }
 }