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

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

There is a newer version: 3.17.0.CR1
Show newest version
package io.quarkus.cli.plugin;

public class PluginListItem {

    private final boolean installed;
    private final Plugin plugin;

    public PluginListItem(boolean installed, Plugin plugin) {
        this.installed = installed;
        this.plugin = plugin;
    }

    public boolean isInstalled() {
        return installed;
    }

    public String getSymbol() {
        return installed ? "*" : " ";
    }

    public String getName() {
        return plugin.getName();
    }

    public String getType() {
        return plugin.getType().name();
    }

    public String getScope() {
        return plugin.isInUserCatalog() ? "user" : "project";
    }

    public String getLocation() {
        return plugin.getLocation().orElse("");
    }

    public String getDescription() {
        return plugin.getDescription().orElse("");
    }

    public String getCommand() {
        switch (plugin.getType()) {
            case jar:
            case maven:
                return "jbang " + plugin.getLocation().orElse("");
            case jbang:
                return "jbang " + plugin.getLocation().orElse(plugin.getName());
            case executable:
                return plugin.getLocation().orElse("");
            default:
                return "";
        }
    }

    public String[] getFields() {
        return getFields(false);
    }

    public String[] getFields(boolean withCommand) {
        return withCommand
                ? new String[] { getSymbol(), getName(), getType(), getScope(), getLocation(), getDescription(), getCommand() }
                : new String[] { getSymbol(), getName(), getType(), getScope(), getLocation(), getDescription() };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy