@Override
    public Integer call() throws Exception {
        super.call();

        if (this.pluginsPath == null) {
            throw new CommandLine.ParameterException(this.spec.commandLine(), "Missing required options '--plugins' " +
                "or environment variable 'KESTRA_PLUGINS_PATH"
            );
        }

        if (!pluginsPath.toFile().exists()) {
            if (!pluginsPath.toFile().mkdir()) {
                throw new RuntimeException("Cannot create directory: " + pluginsPath.toFile().getAbsolutePath());
            }
        }

        if (repositories != null) {
            Arrays.stream(repositories)
                .forEach(throwConsumer(s -> {
                    URIBuilder uriBuilder = new URIBuilder(s);

                    RepositoryConfig.RepositoryConfigBuilder builder = RepositoryConfig.builder()
                        .id(IdUtils.create());

                    if (uriBuilder.getUserInfo() != null) {
                        int index = uriBuilder.getUserInfo().indexOf(":");

                        builder.basicAuth(new RepositoryConfig.BasicAuth(
                            uriBuilder.getUserInfo().substring(0, index),
                            uriBuilder.getUserInfo().substring(index + 1)
                        ));

                        uriBuilder.setUserInfo(null);
                    }

                    builder.url(uriBuilder.build().toString());

                    pluginDownloader.addRepository(builder.build());
                }));
        }

        List<URL> resolveUrl = pluginDownloader.resolve(dependencies);
        stdOut("Resolved Plugin(s) with {0}", resolveUrl);

        for (URL url: resolveUrl) {
            Files.copy(
                Paths.get(url.toURI()),
                Paths.get(pluginsPath.toString(), FilenameUtils.getName(url.toString())),
                StandardCopyOption.REPLACE_EXISTING
            );
        }

        stdOut("Successfully installed plugins {0} into {1}", dependencies, pluginsPath);

        return 0;
    }
@Test
    void rangeVersion() throws IOException {
        Path pluginsPath = Files.createTempDirectory(PluginInstallCommandTest.class.getSimpleName());
        pluginsPath.toFile().deleteOnExit();

        try (ApplicationContext ctx = ApplicationContext.run(Environment.CLI, Environment.TEST)) {
            // SNAPSHOT are included in the 0.12 range not the 0.13, so to avoid resolving it, we must declare it in the upper excluded bound.
            String[] args = {"--plugins", pluginsPath.toAbsolutePath().toString(), "io.kestra.storage:storage-s3:[0.12,0.13.0-SNAPSHOT)"};
            PicocliRunner.call(PluginInstallCommand.class, ctx, args);

            List<Path> files = Files.list(pluginsPath).toList();

            assertThat(files.size(), is(1));
            assertThat(files.getFirst().getFileName().toString(), is("storage-s3-0.12.1.jar"));
        }
    }