This is an automated email from the ASF dual-hosted git repository.

fmariani pushed a commit to branch jbang-user-config
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6f0341727ae3b9c5b2c46f64d3aef44eddcb5288
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Mar 7 15:24:02 2023 +0100

    CAMEL-18508: camel-jbang - User config. WIP
---
 .../dsl/jbang/core/common/CommandLineHelper.java   | 50 ----------------------
 1 file changed, 50 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandLineHelper.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandLineHelper.java
index d189d1321a4..b3fda856a4f 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandLineHelper.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandLineHelper.java
@@ -18,14 +18,7 @@ package org.apache.camel.dsl.jbang.core.common;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
 import java.util.Properties;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 
 import org.apache.camel.util.IOHelper;
 import picocli.CommandLine;
@@ -55,49 +48,6 @@ public class CommandLineHelper {
                 IOHelper.close(fis);
             }
         }
-
-        // TODO: if we need to do this (must be slower due all the command 
options parsing)
-        // this filters the list of options to only what the commands support
-        // Properties options = augmentConfiguration(configuration, 
commandLine);
-        // commandLine.setDefaultValueProvider(new 
CommandLine.PropertiesDefaultProvider(options));
-    }
-
-    private static Properties augmentConfiguration(Properties configuration, 
CommandLine commandLine) {
-        Properties answer = new Properties();
-
-        // gather for all commands every option they have
-        List<String> allOptions
-                = commonArgumentList(new ArrayList<>(), 
commandLine.getSubcommands(), commandLine.getCommandName());
-        allOptions.forEach(key -> {
-            String[] parts = key.split(Pattern.quote("."));
-            String arg = parts[parts.length - 1];
-            // for every option see if we have a configuration for that
-            String value = configuration.getProperty(arg);
-            if (value != null) {
-                answer.setProperty(arg, value);
-            }
-        });
-        return configuration;
-    }
-
-    private static List<String> commonArgumentList(
-            List<String> list, Map<String, CommandLine> commandLines, String 
parentPrefix) {
-        commandLines.forEach((name, subCommand) -> {
-            subCommand.getCommandSpec().args().stream()
-                    .filter(arg -> arg instanceof CommandLine.Model.OptionSpec)
-                    .map(arg -> (CommandLine.Model.OptionSpec) arg)
-                    .map(arg -> arg.longestName().replace("--", ""))
-                    .forEach(arg -> list.add(generateParameter(parentPrefix, 
subCommand.getCommandName(), arg)));
-            // add arguments for sub commands as well
-            list.addAll(
-                    commonArgumentList(new ArrayList<>(), 
subCommand.getSubcommands(), generateParameter(parentPrefix, name)));
-        });
-        return list;
     }
 
-    private static String generateParameter(String... prefix) {
-        return Arrays.stream(prefix)
-                .filter(Objects::nonNull)
-                .collect(Collectors.joining("."));
-    }
 }

Reply via email to