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

        try (var files = Files.walk(directory)) {
            List<String> flows = files
                .filter(Files::isRegularFile)
                .filter(YamlFlowParser::isValidExtension)
                .map(path -> {
                    try {
                        return IncludeHelperExpander.expand(Files.readString(path, Charset.defaultCharset()), path.getParent());
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                })
                .toList();

            String body = "";
            if (flows.isEmpty()) {
                stdOut("No flow found on '{}'", directory.toFile().getAbsolutePath());
            } else {
                body = String.join("\n---\n", flows);
            }
            try(DefaultHttpClient client = client()) {
                MutableHttpRequest<String> request = HttpRequest
                    .POST(apiUri("/flows/") + namespace + "?delete=" + delete, body).contentType(MediaType.APPLICATION_YAML);

                List<UpdateResult> updated = client.toBlocking().retrieve(
                    this.requestOptions(request),
                    Argument.listOf(UpdateResult.class)
                );

                stdOut(updated.size() + " flow(s) for namespace '" + namespace + "' successfully updated !");
                updated.forEach(flow -> stdOut("- " + flow.getNamespace() + "."  + flow.getId()));
            } catch (HttpClientResponseException e){
                FlowValidateCommand.handleHttpException(e, "flow");
                return 1;
            }
        } catch (ConstraintViolationException e) {
            FlowValidateCommand.handleException(e, "flow");

            return 1;
        }

        return 0;
    }
@Test
    void runWithDelete()  {
        URL directory = FlowNamespaceUpdateCommandTest.class.getClassLoader().getResource("flows");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        System.setOut(new PrintStream(out));
        URL subDirectory = FlowNamespaceUpdateCommandTest.class.getClassLoader().getResource("flows/flowsSubFolder");

        try (ApplicationContext ctx = ApplicationContext.run(Environment.CLI, Environment.TEST)) {

            EmbeddedServer embeddedServer = ctx.getBean(EmbeddedServer.class);
            embeddedServer.start();

            String[] args = {
                "--server",
                embeddedServer.getURL().toString(),
                "--user",
                "myuser:pass:word",
                "--delete",
                "io.kestra.cli",
                directory.getPath(),
            };
            PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args);

            assertThat(out.toString(), containsString("3 flow(s)"));
            out.reset();

            args = new String[]{
                "--server",
                embeddedServer.getURL().toString(),
                "--user",
                "myuser:pass:word",
                "--delete",
                "io.kestra.cli",
                subDirectory.getPath(),

            };
            PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args);

            // 2 delete + 1 update
            assertThat(out.toString(), containsString("3 flow(s)"));
        }
    }