You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2024/02/21 23:05:59 UTC

(activemq-artemis) branch main updated: ARTEMIS-4650 PWD CLI Command

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

clebertsuconic 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 4c0ed67897 ARTEMIS-4650 PWD CLI Command
4c0ed67897 is described below

commit 4c0ed678979ed970927b27dae273825ea5359091
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Mon Feb 19 16:17:17 2024 -0500

    ARTEMIS-4650 PWD CLI Command
    
    little tool showing current folders on the CLI. Useful to figure out where you're at when using the shell.
    
    I get myself typing pwd all the time I am using the CLI, trying to figure out what is my current location and broker being used.
    this would be useful to make sure you are going to use the right broker when multiple CLI instances are running from multiple terminals.
---
 .../org/apache/activemq/artemis/cli/Artemis.java   |  3 ++
 .../apache/activemq/artemis/cli/commands/PWD.java  | 42 ++++++++++++++++++++++
 2 files changed, 45 insertions(+)

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 9ec56313e5..af60285461 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
@@ -36,6 +36,7 @@ import org.apache.activemq.artemis.cli.commands.InputAbstract;
 import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
 import org.apache.activemq.artemis.cli.commands.Kill;
 import org.apache.activemq.artemis.cli.commands.Mask;
+import org.apache.activemq.artemis.cli.commands.PWD;
 import org.apache.activemq.artemis.cli.commands.PrintVersion;
 import org.apache.activemq.artemis.cli.commands.Run;
 import org.apache.activemq.artemis.cli.commands.Stop;
@@ -257,6 +258,8 @@ public class Artemis implements Runnable {
       help.setCommandLine(commandLine);
       commandLine.addSubcommand(help);
 
+      commandLine.addSubcommand(new PWD());
+
       commandLine.addSubcommand(new AutoCompletion());
 
       // we don't include the shell in the shell
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/PWD.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/PWD.java
new file mode 100644
index 0000000000..29ec8a7172
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/PWD.java
@@ -0,0 +1,42 @@
+/*
+ * 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.activemq.artemis.cli.commands;
+
+import picocli.CommandLine;
+
+@CommandLine.Command(name = "pwd", description = "Information on current folder and instance.")
+public class PWD extends ActionAbstract {
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      super.execute(context);
+
+      System.out.println();
+      System.out.println("*******************************************************************************************************************************");
+      System.out.println("* Artemis instance:: " + getBrokerInstance());
+      System.out.println("* Home:: " + getBrokerHome());
+      System.out.println("* etc:: " + getBrokerEtc());
+
+      String canonicalPath = new java.io.File(".").getCanonicalPath();
+      System.out.println("* Current dir:" + canonicalPath);
+      System.out.println("*******************************************************************************************************************************");
+      System.out.println();
+
+      return null;
+   }
+}
\ No newline at end of file