forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#9783 from stalep/aesh_cli
- Loading branch information
Showing
23 changed files
with
943 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 8 additions & 50 deletions
58
devtools/aesh/src/main/java/io/quarkus/cli/QuarkusCli.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
devtools/aesh/src/main/java/io/quarkus/cli/commands/AddExtensionCommand.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.