ARTEMIS-3226 Add version output to cli
This commit is contained in:
parent
a195790005
commit
78401dcf64
|
@ -31,6 +31,7 @@ import org.apache.activemq.artemis.cli.commands.InputAbstract;
|
||||||
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
||||||
import org.apache.activemq.artemis.cli.commands.Kill;
|
import org.apache.activemq.artemis.cli.commands.Kill;
|
||||||
import org.apache.activemq.artemis.cli.commands.Mask;
|
import org.apache.activemq.artemis.cli.commands.Mask;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.PrintVersion;
|
||||||
import org.apache.activemq.artemis.cli.commands.check.HelpCheck;
|
import org.apache.activemq.artemis.cli.commands.check.HelpCheck;
|
||||||
import org.apache.activemq.artemis.cli.commands.check.NodeCheck;
|
import org.apache.activemq.artemis.cli.commands.check.NodeCheck;
|
||||||
import org.apache.activemq.artemis.cli.commands.check.QueueCheck;
|
import org.apache.activemq.artemis.cli.commands.check.QueueCheck;
|
||||||
|
@ -155,7 +156,9 @@ public class Artemis {
|
||||||
|
|
||||||
private static Cli.CliBuilder<Action> builder(File artemisInstance) {
|
private static Cli.CliBuilder<Action> builder(File artemisInstance) {
|
||||||
String instance = artemisInstance != null ? artemisInstance.getAbsolutePath() : System.getProperty("artemis.instance");
|
String instance = artemisInstance != null ? artemisInstance.getAbsolutePath() : System.getProperty("artemis.instance");
|
||||||
Cli.CliBuilder<Action> builder = Cli.<Action>builder("artemis").withDescription("ActiveMQ Artemis Command Line").withCommand(HelpAction.class).withCommand(Producer.class).withCommand(Transfer.class).withCommand(Consumer.class).withCommand(Browse.class).withCommand(Mask.class).withDefaultCommand(HelpAction.class);
|
Cli.CliBuilder<Action> builder = Cli.<Action>builder("artemis").withDescription("ActiveMQ Artemis Command Line").
|
||||||
|
withCommand(HelpAction.class).withCommand(Producer.class).withCommand(Transfer.class).withCommand(Consumer.class).
|
||||||
|
withCommand(Browse.class).withCommand(Mask.class).withCommand(PrintVersion.class).withDefaultCommand(HelpAction.class);
|
||||||
|
|
||||||
builder.withGroup("check").withDescription("Check tools group (node|queue) (example ./artemis check node)").
|
builder.withGroup("check").withDescription("Check tools group (node|queue) (example ./artemis check node)").
|
||||||
withDefaultCommand(HelpCheck.class).withCommands(NodeCheck.class, QueueCheck.class);
|
withDefaultCommand(HelpCheck.class).withCommands(NodeCheck.class, QueueCheck.class);
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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 io.airlift.airline.Command;
|
||||||
|
import org.apache.activemq.artemis.core.version.Version;
|
||||||
|
import org.apache.activemq.artemis.utils.VersionLoader;
|
||||||
|
|
||||||
|
@Command(name = "version", description = "print version information")
|
||||||
|
public class PrintVersion extends ActionAbstract {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ActionContext context) throws Exception {
|
||||||
|
Version version = VersionLoader.getVersion();
|
||||||
|
|
||||||
|
context.out.println("Apache ActiveMQ Artemis " + version.getFullVersion());
|
||||||
|
context.out.println("ActiveMQ Artemis home: " + this.getBrokerHome());
|
||||||
|
context.out.println("ActiveMQ Artemis instance: " + this.getBrokerInstance());
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,7 @@ import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.Create;
|
import org.apache.activemq.artemis.cli.commands.Create;
|
||||||
import org.apache.activemq.artemis.cli.commands.Mask;
|
import org.apache.activemq.artemis.cli.commands.Mask;
|
||||||
import org.apache.activemq.artemis.cli.commands.Run;
|
import org.apache.activemq.artemis.cli.commands.Run;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.PrintVersion;
|
||||||
import org.apache.activemq.artemis.cli.commands.queue.StatQueue;
|
import org.apache.activemq.artemis.cli.commands.queue.StatQueue;
|
||||||
import org.apache.activemq.artemis.cli.commands.user.AddUser;
|
import org.apache.activemq.artemis.cli.commands.user.AddUser;
|
||||||
import org.apache.activemq.artemis.cli.commands.user.ListUser;
|
import org.apache.activemq.artemis.cli.commands.user.ListUser;
|
||||||
|
@ -74,6 +75,7 @@ import org.apache.activemq.artemis.core.security.impl.SecurityStoreImpl;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||||
import org.apache.activemq.artemis.core.server.JournalType;
|
import org.apache.activemq.artemis.core.server.JournalType;
|
||||||
import org.apache.activemq.artemis.core.server.management.ManagementContext;
|
import org.apache.activemq.artemis.core.server.management.ManagementContext;
|
||||||
|
import org.apache.activemq.artemis.core.version.Version;
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||||
import org.apache.activemq.artemis.nativo.jlibaio.LibaioContext;
|
import org.apache.activemq.artemis.nativo.jlibaio.LibaioContext;
|
||||||
|
@ -1742,6 +1744,14 @@ public class ArtemisTest extends CliTestBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVersionCommand() throws Exception {
|
||||||
|
TestActionContext context = new TestActionContext();
|
||||||
|
PrintVersion printVersion = new PrintVersion();
|
||||||
|
Version result = (Version) printVersion.execute(context);
|
||||||
|
log.debug(context.getStdout());
|
||||||
|
}
|
||||||
|
|
||||||
//read individual lines from byteStream
|
//read individual lines from byteStream
|
||||||
public static ArrayList<String> getOutputLines(TestActionContext context, boolean errorOutput) throws IOException {
|
public static ArrayList<String> getOutputLines(TestActionContext context, boolean errorOutput) throws IOException {
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
|
|
Loading…
Reference in New Issue