Skip to content

Commit

Permalink
Merge pull request #9783 from stalep/aesh_cli
Browse files Browse the repository at this point in the history
  • Loading branch information
stalep authored Jun 16, 2020
2 parents ea988c9 + 2013ebb commit ed73ae5
Show file tree
Hide file tree
Showing 23 changed files with 943 additions and 220 deletions.
2 changes: 1 addition & 1 deletion bom/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<packaging>pom</packaging>

<properties>
<aesh.version>1.11</aesh.version>
<aesh.version>2.5</aesh.version>
<jandex.version>2.1.3.Final</jandex.version>
<resteasy.version>4.5.3.Final</resteasy.version>
<opentracing.version>0.31.0</opentracing.version>
Expand Down
75 changes: 74 additions & 1 deletion devtools/aesh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,85 @@
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

<!-- not used atm
<repositories>
<repository>
<id>gradle-repo</id>
<url>https://repo.gradle.org/gradle/libs-releases-local/</url>
</repository>
</repositories>
-->
<dependencies>
<!-- Compile -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-core</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devtools-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-development-mode-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-platform-descriptor-json</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-platform-descriptor-resolver-json</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</dependency>
-->
<!-- Gradle, not used atm
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-tooling-api</artifactId>
<version>6.3</version>
</dependency> -->

<dependency>
<groupId>org.aesh</groupId>
<artifactId>aesh</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>${project.basedir}/../bom-descriptor-json/target</directory>
<targetPath>quarkus-bom-descriptor</targetPath>
<filtering>false</filtering>
<includes>
<include>extensions.json</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down Expand Up @@ -65,10 +126,21 @@
</execution>
</executions>
</plugin>
<!-- fails for the bom-descriptor-json -->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.quarkus.cli.QuarkusCli</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -78,6 +150,7 @@
<configuration>
<artifactSet>
<excludes>
<exclude>io.quarkus:quarkus-bom-descriptor-json</exclude>
<exclude>org.fusesource.jansi:jansi</exclude>
<exclude>org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain</exclude>
<exclude>junit:junit</exclude>
Expand Down
23 changes: 15 additions & 8 deletions devtools/aesh/reflectconfigs/quarkuscli.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "help" }
{ "name" : "extensions" },
{ "name" : "path" }
]
},
{
Expand All @@ -16,10 +17,13 @@
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "help" },
{ "name" : "artifactid" },
{ "name" : "groupid" },
{ "name" : "artifactId" },
{ "name" : "groupId" },
{ "name" : "version" },
{ "name" : "className" },
{ "name" : "resourcePath" },
{ "name" : "buildTool" },
{ "name" : "extensions" },
{ "name" : "path" }
]
},
Expand All @@ -30,19 +34,22 @@
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "help" }
{ "name" : "all" },
{ "name" : "format" },
{ "name" : "searchPattern" },
{ "name" : "path" }
]
},
{
"name" : "io.quarkus.cli.commands.QuarkusCommand",
"name" : "io.quarkus.cli.commands.QuarkusBaseCommand",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "help" }
{ "name" : "interactive" }
]
},
},
{
"name" : "org.aesh.command.impl.completer.BooleanOptionCompleter",
"allDeclaredConstructors" : true,
Expand Down
58 changes: 8 additions & 50 deletions devtools/aesh/src/main/java/io/quarkus/cli/QuarkusCli.java
Original file line number Diff line number Diff line change
@@ -1,59 +1,17 @@
package io.quarkus.cli;

import java.io.IOException;
import org.aesh.AeshRuntimeRunner;

import org.aesh.command.AeshCommandRuntimeBuilder;
import org.aesh.command.CommandException;
import org.aesh.command.CommandNotFoundException;
import org.aesh.command.CommandRuntime;
import org.aesh.command.impl.registry.AeshCommandRegistryBuilder;
import org.aesh.command.parser.CommandLineParserException;
import org.aesh.command.registry.CommandRegistryException;
import org.aesh.command.validator.CommandValidatorException;
import org.aesh.command.validator.OptionValidatorException;

import io.quarkus.cli.commands.QuarkusCommand;
import io.quarkus.cli.commands.QuarkusBaseCommand;

public class QuarkusCli {

public static void main(String[] args) throws CommandRegistryException {
CommandRuntime runtime = AeshCommandRuntimeBuilder
.builder()
.commandRegistry(AeshCommandRegistryBuilder.builder().command(QuarkusCommand.class).create())
.build();

if (args.length > 0) {
StringBuilder sb = new StringBuilder(QuarkusCommand.COMMAND_NAME).append(" ");
if (args.length == 1) {
sb.append(args[0]);
} else {
for (String arg : args) {
if (arg.indexOf(' ') >= 0) {
sb.append('"').append(arg).append("\" ");
} else {
sb.append(arg).append(' ');
}
}
}

try {
runtime.executeCommand(sb.toString());
} catch (CommandNotFoundException e) {
System.err.println("Command not found: " + sb.toString());
} catch (CommandException | CommandLineParserException | CommandValidatorException | OptionValidatorException e) {
showHelpIfNeeded(runtime, e);
} catch (InterruptedException | IOException e) {
System.err.println(e.getMessage());
}
} else {
showHelpIfNeeded(runtime, null);
}
public static void main(String[] args) {
AeshRuntimeRunner.builder()
.command(QuarkusBaseCommand.class)
.args(args)
.interactive(true)
.execute();
}

private static void showHelpIfNeeded(CommandRuntime runtime, Exception e) {
if (e != null) {
System.err.println(e.getMessage());
}
System.err.println(runtime.commandInfo(QuarkusCommand.COMMAND_NAME));
}
}

This file was deleted.

Loading

0 comments on commit ed73ae5

Please sign in to comment.