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

jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 90723c18fb ARTEMIS-5111 improve how auto-completion is handled in 
artemis
90723c18fb is described below

commit 90723c18fb213075e389b073335ba180df48f5de
Author: Clebert Suconic <[email protected]>
AuthorDate: Tue Oct 15 12:39:55 2024 -0400

    ARTEMIS-5111 improve how auto-completion is handled in artemis
    
    Other projects like quarkus will do source <(./artemis completion)
    
    This seem more standard and easier to understand.
---
 .../org/apache/activemq/artemis/cli/Artemis.java   |  3 ++
 .../artemis/cli/commands/AutoCompletion.java       |  2 +-
 .../{AutoCompletion.java => Completion.java}       | 27 +++--------
 docs/user-manual/using-cli.adoc                    | 56 ++++++++++------------
 4 files changed, 37 insertions(+), 51 deletions(-)

diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
index c8725c95d3..0bc35f5587 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
@@ -29,6 +29,7 @@ import java.util.Objects;
 import org.apache.activemq.artemis.cli.commands.Action;
 import org.apache.activemq.artemis.cli.commands.ActionContext;
 import org.apache.activemq.artemis.cli.commands.AutoCompletion;
+import org.apache.activemq.artemis.cli.commands.Completion;
 import org.apache.activemq.artemis.cli.commands.Create;
 import org.apache.activemq.artemis.cli.commands.Disconnect;
 import org.apache.activemq.artemis.cli.commands.HelpAction;
@@ -302,6 +303,8 @@ public class Artemis implements Runnable {
          commandLine.addSubcommand(new Upgrade());
       }
 
+      commandLine.addSubcommand(new Completion());
+
       return commandLine;
    }
 
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AutoCompletion.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AutoCompletion.java
index 4f5ae4d912..96de919d99 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AutoCompletion.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AutoCompletion.java
@@ -26,7 +26,7 @@ import picocli.CommandLine.Parameters;
 import picocli.CommandLine.Option;
 import picocli.CommandLine.Command;
 
-@Command(name = "auto-complete", description = "Generates the auto complete 
script file to be used in bash or zsh.")
+@Command(name = "auto-complete", description = "Generates the auto complete 
script file to be used in bash or zsh. This feature is deprecated in favor of 
./artemis completion", hidden = true)
 public class AutoCompletion implements Runnable {
 
    public AutoCompletion() {
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AutoCompletion.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Completion.java
similarity index 56%
copy from 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AutoCompletion.java
copy to 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Completion.java
index 4f5ae4d912..fe15ee3a3b 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AutoCompletion.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Completion.java
@@ -17,46 +17,33 @@
 
 package org.apache.activemq.artemis.cli.commands;
 
-import java.io.File;
-
 import org.apache.activemq.artemis.cli.Artemis;
 import picocli.AutoComplete;
 import picocli.CommandLine;
-import picocli.CommandLine.Parameters;
-import picocli.CommandLine.Option;
 import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
 
-@Command(name = "auto-complete", description = "Generates the auto complete 
script file to be used in bash or zsh.")
-public class AutoCompletion implements Runnable {
+@Command(name = "completion", description = "Generates the auto complete 
script file to be used in bash or zsh. Usage: source <(./artemis completion)")
+public class Completion implements Runnable {
 
-   public AutoCompletion() {
+   public Completion() {
    }
-
    @Option(names = "--start-script", description = "the script used to start 
artemis. (default ./artemis)", defaultValue = "./artemis")
    String startScript;
 
-   @Parameters (description = "The generated auto-complete script", 
defaultValue = "auto-complete-artemis.sh")
-   File autoCompleteFile;
-
-
    @Override
    public void run() {
       try {
          CommandLine artemisCommand = Artemis.buildCommand(true, true, true);
-         AutoComplete.bash(startScript, autoCompleteFile, null, 
artemisCommand);
-         System.out.println("Type the following commands before you can use 
auto-complete:");
-         
System.out.println("*******************************************************************************************************************************");
-         System.out.println("source " + autoCompleteFile.getAbsolutePath());
-         
System.out.println("*******************************************************************************************************************************");
-
+         System.out.print(AutoComplete.bash(startScript, artemisCommand));
       } catch (Throwable e) {
          e.printStackTrace();
       }
    }
 
-   // I'm letting the possibility of calling AutoCompletion directly bypassing 
the artemis CLI.
+   // I'm letting the possibility of calling Completion directly bypassing the 
artemis CLI.
    public static void main(String[] args) {
-      CommandLine commandLine = new CommandLine(new AutoCompletion());
+      CommandLine commandLine = new CommandLine(new Completion());
       commandLine.execute(args);
    }
 }
diff --git a/docs/user-manual/using-cli.adoc b/docs/user-manual/using-cli.adoc
index 5a936edca4..3bca10c703 100644
--- a/docs/user-manual/using-cli.adoc
+++ b/docs/user-manual/using-cli.adoc
@@ -25,25 +25,28 @@ $ ./artemis help
 Usage: artemis [COMMAND]
 ActiveMQ Artemis Command Line
 Commands:
-  help           use 'help <command>' for more information
-  auto-complete  Generates the auto complete script file to be used in bash or
-                   zsh.
-  shell          JLine3 shell helping using the CLI
-  producer       Send message(s) to a broker.
-  transfer       Move messages from one destination towards another 
destination.
-  consumer       Consume messages from a queue.
-  browser        Browse messages on a queue.
-  mask           Mask a password and print it out.
-  version        Print version information.
-  perf           use 'help perf' for sub commands list
-  check          use 'help check' for sub commands list
-  queue          use 'help check' for sub commands list
-  address        use 'help address' for sub commands list
-  data           use 'help data' for sub commands list
-  create         Create a new broker instance.
-  upgrade        Update a broker instance to the current artemis.home, keeping
-                   all the data and broker.xml. Warning: backup your instance
-                   before using this command and compare the files.
+  help        use 'help <command>' for more information
+  pwd         Information on current folder and instance.
+  shell       JLine3 shell helping using the CLI
+  producer    Send message(s) to a broker.
+  transfer    Move messages from one destination towards another destination.
+  consumer    Consume messages from a queue.
+  browser     Browse messages on a queue.
+  mask        Mask a password and print it out.
+  version     Print version information.
+  perf        use 'help perf' for sub commands list
+  check       use 'help check' for sub commands list
+  queue       use 'help queue' for sub commands list
+  address     use 'help address' for sub commands list
+  connect     Connect to the broker validating credentials for commands.
+  disconnect  Clear previously typed user credentials.
+  data        use 'help data' for sub commands list
+  create      Create a new broker instance.
+  upgrade     Update a broker instance to the current artemis.home, keeping all
+                the data and broker.xml. Warning: backup your instance before
+                using this command and compare the files.
+  completion  Generates the auto complete script file to be used in bash or
+                zsh. Usage: source <(./artemis completion)
 ----
 
 It is also possible to use `help` at a specific command or sub-command for 
more information.
@@ -285,14 +288,7 @@ Bash and Zsh provide ways to auto-complete commands. To 
integrate with that func
 
 [,console]
 ----
-$ ./artemis auto-complete
-----
-
-This will generate a file named `auto-complete-artemis.sh` that can be 
installed using:
-
-[,console]
-----
-$ source ./auto-complete-artemis.sh
+$ source <(./artemis completion)
 ----
 
 After the auto-completion is installed you can view auto-completion 
information by pressing kbd:[TAB]:
@@ -300,9 +296,9 @@ After the auto-completion is installed you can view 
auto-completion information
 [,console]
 ----
 $ ./artemis
-activation     browser        create         kill           perf-journal   run 
           transfer       version
-address        check          data           mask           producer       
shell          upgrade
-auto-complete  consumer       help           perf           queue          
stop           user
+activation    check         consumer      disconnect    mask          producer 
     run           transfer      version
+address       completion    create        help          perf          pwd      
     shell         upgrade
+browser       connect       data          kill          perf-journal  queue    
     stop          user
 ----
 
 In order to see the various parameters available you must type `--` then press 
kbd:[TAB]:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to