This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new a356ebce105 CAMEL-18715: camel-jbang - Run with --local-kamelet-dir can now point to github/gist link as well. a356ebce105 is described below commit a356ebce105ed3a50332843190324a2dd6200091 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sun Dec 4 12:03:08 2022 +0100 CAMEL-18715: camel-jbang - Run with --local-kamelet-dir can now point to github/gist link as well. --- .../java/org/apache/camel/dsl/jbang/core/commands/Run.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java index f67bdf16d8a..05b145615d9 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java @@ -66,6 +66,7 @@ import picocli.CommandLine.Command; import picocli.CommandLine.Option; import picocli.CommandLine.Parameters; +import static org.apache.camel.dsl.jbang.core.common.GistHelper.asGistSingleUrl; import static org.apache.camel.dsl.jbang.core.common.GistHelper.fetchGistUrls; import static org.apache.camel.dsl.jbang.core.common.GitHubHelper.asGithubSingleUrl; import static org.apache.camel.dsl.jbang.core.common.GitHubHelper.fetchGithubUrls; @@ -170,7 +171,7 @@ class Run extends CamelCommand { String jfrProfile; @Option(names = { "--local-kamelet-dir" }, - description = "Local directory for loading Kamelets (takes precedence). Multiple directories can be specified separated by comma.") + description = "Local directory (or github link) for loading Kamelets (takes precedence). Multiple directories can be specified separated by comma.") String localKameletDir; @Option(names = { "--port" }, description = "Embeds a local HTTP server on this port") @@ -638,7 +639,7 @@ class Run extends CamelCommand { return file; } - private KameletMain createMainInstance() { + private KameletMain createMainInstance() throws Exception { KameletMain main; if (localKameletDir == null || localKameletDir.isEmpty()) { main = new KameletMain(); @@ -646,8 +647,14 @@ class Run extends CamelCommand { StringJoiner sj = new StringJoiner(","); String[] parts = localKameletDir.split(","); for (String part : parts) { + // automatic map github https urls to github resolver + if (part.startsWith("https://github.com/")) { + part = asGithubSingleUrl(part); + } else if (part.startsWith("https://gist.github.com/")) { + part = asGistSingleUrl(part); + } part = FileUtil.compactPath(part); - if (!ResourceHelper.hasScheme(part)) { + if (!ResourceHelper.hasScheme(part) && !part.startsWith("github:")) { part = "file:" + part; } sj.add(part);