<commit_before>= Camel JBang

A JBang-based Camel app for easily running Camel routes.

== Installation

First you must install https://www.jbang.dev/[JBang] which is used for launching Camel.
See instructions on https://www.jbang.dev/download/[JBang] how to download and install.

After JBang is installed you can verify JBang is working by executing the following command from a command shell:

[source,bash]
----
jbang version
----

Which should output the version of JBang.

To make it easier to use Camel JBang then install the following:

[source,bash]
----
jbang app install camel@apache/camel
----

This will install Apache Camel as the `camel` command within JBang, meaning that you can run Camel from the command line
by just executing `camel` (see more next).

== Using Camel JBang

The Camel JBang supports multiple commands. Running the command below, will print all of them:

[source,bash]
----
camel --help
----

TIP: The first time you run this command, it may cause dependencies to be cached, therefore taking a few extra seconds to run.

All the commands support the `--help` and will display the appropriate help if that flag is provided.

== Creating and running Camel routes

You can create a new basic routes with the `init` command.

For example to create an XML route you do:

[source,bash]
----
camel init cheese.xml
----

Which creates the file `cheese.xml` with a sample route.

To run the file, you simply do:

[source,bash]
----
camel run cheese.xml
----

NOTE: You can create and run any of the supported xref:dsl.adoc[DSLs] in Camel such as YAML, XML, Java, Groovy.

To create a new .java integration, you simply do:

[source,bash]
----
camel init foo.java
----

=== Running Routes from multiple files

You can run more than 1 file, for example to run two YAML files you can do:

[source,bash]
----
camel run one.yaml two.yaml
----

You can also mix different xref:dsl.adoc[DSLs] such as yaml and Java:

[source,bash]
----
camel run one.yaml hello.java
----

You can also use wildcards (i.e. `*`) to match multiple files, such as running all the yaml files:

[source,bash]
----
camel run *.yaml
----

Or you can run all files starting with foo*

[source,bash]
----
camel run foo*
----

TIP: The run goal can also detect files that are `properties`.

=== Dev mode with live reload

You can enable dev mode that comes with live reload of the route(s) when the source file is updated (saved),
using the `--dev` options as shown:

[source,bash]
----
camel run jms-amqp-10-sink-binding.yaml --dev
----

Then while the Camel application is running, you can update the YAML route and update when saving.

NOTE: The live reload is meant for development purposes, and if you encounter problems with reloading
such as JVM class loading issues, then you may need to restart the application.

=== Using profiles

Camel JBang have the concept of profiles. A _profile_ is essentially a name (id) that refers
to which configuration to automatic load with Camel JBang. The default profile is named `application`
which is a (smart default) to let Camel JBang automatic load `application.properties` (if present).

This means that creating profiles matching to a properties file with the same name.

For example having a profile named `local`, means that Camel JBang will load `local.properties` instead
of `application.properties`.

To use a profile, you specify as command line option `--profile` such as:
<commit_msg>camel-jbang - Polished docs<commit_after>= Camel JBang

A JBang-based Camel app for easily running Camel routes.

== Installation

First you must install https://www.jbang.dev/[JBang] which is used for launching Camel.
See instructions on https://www.jbang.dev/download/[JBang] how to download and install.

After JBang is installed you can verify JBang is working by executing the following command from a command shell:

[source,bash]
----
jbang version
----

Which should output the version of JBang.

To make it easier to use Camel JBang then install the following:

[source,bash]
----
jbang app install camel@apache/camel
----

This will install Apache Camel as the `camel` command within JBang, meaning that you can run Camel from the command line
by just executing `camel` (see more next).

== Using Camel JBang

The Camel JBang supports multiple commands. Running the command below, will print all of them:

[source,bash]
----
camel --help
----

TIP: The first time you run this command, it may cause dependencies to be cached, therefore taking a few extra seconds to run.

All the commands support the `--help` and will display the appropriate help if that flag is provided.

== Creating and running Camel routes

You can create a new basic routes with the `init` command.

For example to create an XML route you do:

[source,bash]
----
camel init cheese.xml
----

Which creates the file `cheese.xml` with a sample route.

To run the file, you simply do:

[source,bash]
----
camel run cheese.xml
----

NOTE: You can create and run any of the supported xref:dsl.adoc[DSLs] in Camel such as YAML, XML, Java, Groovy.

To create a new .java route, you simply do:

[source,bash]
----
camel init foo.java
----

=== Running Routes from multiple files

You can run more than 1 file, for example to run two YAML files you can do:

[source,bash]
----
camel run one.yaml two.yaml
----

You can also mix different xref:dsl.adoc[DSLs] such as yaml and Java:

[source,bash]
----
camel run one.yaml hello.java
----

You can also use wildcards (i.e. `*`) to match multiple files, such as running all the yaml files:

[source,bash]
----
camel run *.yaml
----

Or you can run all files starting with foo*

[source,bash]
----
camel run foo*
----

And to run everything

[source,bash]
----
camel run *
----

TIP: The run goal can also detect files that are `properties`.

=== Dev mode with live reload

You can enable dev mode that comes with live reload of the route(s) when the source file is updated (saved),
using the `--dev` options as shown:

[source,bash]
----
camel run foo.yaml --dev
----

Then while the Camel application is running, you can update the YAML route and update when saving.

This works for all DLS even java, so you can do:

[source,bash]
----
camel run hello.java --dev
----

NOTE: The live reload is meant for development purposes, and if you encounter problems with reloading
such as JVM class loading issues, then you may need to restart the application.

=== Using profiles

Camel JBang have the concept of profiles. A _profile_ is essentially a name (id) that refers
to which configuration to automatic load with Camel JBang. The default profile is named `application`
which is a (smart default) to let Camel JBang automatic load `application.properties` (if present).

This means that creating profiles matching to a properties file with the same name.

For example having a profile named `local`, means that Camel JBang will load `local.properties` instead
of `application.properties`.

To use a profile, you specify as command line option `--profile` such as:

{'fraction_non_alphanumeric': 0.08781183178902352, 'fraction_numerical': 0.0005702066999287242, 'mean_word_length': 3.600655737704918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5558288', 'n_tokens_mistral': 2094, 'n_tokens_neox': 2007, 'n_words': 1047}