Agent CLI
For many use cases, your agents won't need a full REST API and all the bells and whistles - you may just need a simple command line application. Run once and done until the next time - or easily setup to run on a scheduled task via AWS.
The SDK provides that functionality out of the box, either as an interactive prompt or accepting parameters when you execute your jar.
Enabling the CLI
The CLI functions as part of a Spring profile. There are two modes - standard CLI (executes one task and exits) or interactive CLI. To use the CLI at all (and pre-configure the local database and disable web endpoints, etc) you must activate the cli
profile. To interact with your agents through a simple prompt interface, you can enable cli-interactive
.
To enable it you can either pass the the profiles as a property in application.properties
as seen below:
spring.profiles.active=cli,cli-interactive
Or you can pass them as a parameter when running your compiled application:
java -Dspring.profiles.active=cli,cli-interactive -jar ./build/libs/sample-all.jar
Running your CLI application
Running your agent CLI is as simple as building the bootJar and then running the combined jar from the folder that contains your project:
./gradlew bootRun
Don't forget that you'll need to set environent variables or have everything contained in your application.properties to run appropriately.
You can also just run ./gradlew bootJar
separately and then run the java -jar
command like we showed above when activating the CLI.
Last updated
Was this helpful?