All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.cli.plugin.JBangCommand Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy