io.quarkus.cli.plugin.JBangCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-cli Show documentation
Show all versions of quarkus-cli Show documentation
Quarkus command line utility
package io.quarkus.cli.plugin;
import java.util.ArrayList;
import java.util.List;
import io.quarkus.cli.common.OutputOptionMixin;
import picocli.CommandLine.Command;
import picocli.CommandLine.ExitCode;
@Command
public class JBangCommand implements PluginCommand {
private String location; //alias, url, maven coords
private JBangSupport jbang;
private OutputOptionMixin output;
private final List arguments = new ArrayList<>();
public JBangCommand() {
super();
}
public JBangCommand(String location, OutputOptionMixin output) {
this.location = location;
this.jbang = new JBangSupport(!output.isCliTest(), output);
this.output = output;
this.arguments.add(location);
}
@Override
public Integer call() throws Exception {
if (jbang.ensureJBangIsInstalled()) {
return PluginCommand.super.call();
} else {
output.error("Unable to find JBang! Command execution aborted!");
return ExitCode.SOFTWARE;
}
}
@Override
public List getCommand() {
return jbang.getCommand();
}
@Override
public List getArguments() {
return arguments;
}
public OutputOptionMixin getOutput() {
return output;
}
@Override
public void useArguments(List arguments) {
this.arguments.clear();
this.arguments.add(location);
this.arguments.addAll(arguments);
}
}