Skip to content

Commit

Permalink
[maven] Enable overrding of the bootique "version" command.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed May 29, 2020
1 parent 5740097 commit 39b3578
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
Expand Up @@ -51,21 +51,42 @@ public class VersionCommand extends CommandWithMetadata {
* @param bootLogger the logger.
*/
public VersionCommand(BootLogger bootLogger) {
this(bootLogger, VersionCommand.class, Messages.VersionCommand_0);
}

/** Constructor.
*
* @param bootLogger the logger.
* @param commandType the type of the command.
* @param description the description of the command.
* @since 0.11
*/
protected VersionCommand(BootLogger bootLogger, Class<? extends VersionCommand> commandType,
String description) {
super(CommandMetadata
.builder(VersionCommand.class)
.description(Messages.VersionCommand_0)
.builder(commandType)
.description(description)
.name(CLI_NAME));
this.bootLogger = bootLogger;
}

@Override
public CommandOutcome run(Cli cli) {
final StringBuilder text = new StringBuilder();
text.append(MessageFormat.format(Messages.VersionCommand_1,
/** Replies the message that should be output by the command.
*
* @return the message.
* @since 0.11
*/
protected String getVersionMessage() {
return MessageFormat.format(Messages.VersionCommand_1,
SARLVersion.SARL_RELEASE_VERSION, SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING,
System.getProperty("java.vm.name"), //$NON-NLS-1$
System.getProperty("java.version"), //$NON-NLS-1$
System.getProperty("java.home"))); //$NON-NLS-1$
System.getProperty("java.home")); //$NON-NLS-1$
}

@Override
public CommandOutcome run(Cli cli) {
final StringBuilder text = new StringBuilder();
text.append(getVersionMessage());
this.bootLogger.stdout(text.toString());
return CommandOutcome.succeeded();
}
Expand Down
@@ -1,3 +1,3 @@
VersionCommand_0 = Prints release information.
VersionCommand_1 = SARL version: {0}\nSARL specification version: {1}\nJava environment: {2}\nJava Java version: {3}\nJava home directory: {4}\n
VersionCommand_1 = SARL version: {0}\nSARL specification version: {1}\nJava environment: {2}\nJava version: {3}\nJava home directory: {4}\n
VersionCommandModuleProvider_0 = The command for printing out the version of this application.

0 comments on commit 39b3578

Please sign in to comment.