@Override
    public Integer doCall() throws Exception {
        JsonObject pluginConfig = loadConfig();
        JsonObject plugins = pluginConfig.getMap("plugins");

        Optional<PluginType> camelPlugin = PluginType.findByName(name);
        if (camelPlugin.isPresent()) {
            if (command == null) {
                command = camelPlugin.get().getCommand();
            }

            if (description == null) {
                description = camelPlugin.get().getDescription();
            }
            if (firstVersion == null) {
                firstVersion = camelPlugin.get().getFirstVersion();
            }
        }

        if (command == null) {
            // use plugin name as command
            command = name;
        }
        if (firstVersion == null) {
            // fallback to version specified
            firstVersion = version;
        }

        JsonObject plugin = new JsonObject();
        plugin.put("name", name);
        plugin.put("command", command);
        if (firstVersion != null) {
            plugin.put("firstVersion", firstVersion);
        }
        plugin.put("description",
                description != null ? description : "Plugin %s called with command %s".formatted(name, command));

        if (gav == null && (groupId != null && artifactId != null)) {
            if (version == null) {
                CamelCatalog catalog = new DefaultCamelCatalog();
                version = catalog.getCatalogVersion();
            }

            gav = "%s:%s:%s".formatted(groupId, artifactId, version);
        }

        if (gav != null) {
            plugin.put("dependency", gav);
        }

        plugins.put(name, plugin);

        saveConfig(pluginConfig);
        return 0;
    }
@Test
    public void shouldAddPlugin() throws Exception {
        PluginAdd command = new PluginAdd(new CamelJBangMain().withPrinter(printer));
        command.name = "foo-plugin";
        command.command = "foo";
        command.description = "Some plugin";
        command.firstVersion = "1.2.3";
        command.doCall();

        Assertions.assertEquals("", printer.getOutput());

        Assertions.assertEquals("{\"plugins\":{\"foo-plugin\":{\"name\":\"foo-plugin\",\"command\":\"foo\"," +
                                "\"firstVersion\":\"1.2.3\",\"description\":\"Some plugin\"}}}",
                PluginHelper.getOrCreatePluginConfig().toJson());
    }