Using the command line interface
To allow remote management of Martini instances via a terminal, all editions (except the Desktop Edition) ship with a command-line interface (CLI) tool.
bin/ directory, run the CLI with:
$ java -jar martini-cli-client.jar
This launches a shell containing commands for managing Martini. To list the available commands, type
help. Note that
the sample text below shows the Martini splash screen which appears when the CLI first launches.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
__ __ _ _ _ | \/ | | | (_) (_) ™ | \ / | __ _ _ __ | |_ _ _ __ _ | |\/| | / _` || '__|| __|| || '_ \ | | | | | || (_| || | | |_ | || | | || | |_| |_| \__,_||_| \__||_||_| |_||_| :: CLI (v1.0.0) :: :: Type `help` to get started. > help AVAILABLE COMMANDS Authentication Commands connect: Connects to a Martini instance. Built-In Commands clear: Clear the shell screen. exit, quit: Exit the shell. help: Display help about available commands. script: Read and execute commands from a file. stacktrace: Display the full stacktrace of the last error. License Commands export-license: Exports the currently installed license in this machine to a file. import-license: Imports a license from the provided file to this machine. install-license: Installs a license to this machine. license: Prints the currently installed license in this machine. product-key: Prints the product key for the installation in this machine. sync-license: Syncs the currently installed license in this machine.
More commands are available when you're logged in
The commands above are only a subset of all available commands. More commands can be executed after logging in via
Connecting to an instance
1 2 3
> connect --uri http://localhost:8080 --username email@example.com --password password Connected. http://localhost:8080 > _
When successful, the prompt changes to the URL of the instance you're currently connected to. You might also notice an increase in the number of executable commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
http://localhost:8080 > help AVAILABLE COMMANDS Authentication Commands connect: Connects to a Martini instance. disconnect: Disconnects from the Martini instance. whoami: Prints the current active user. Broker Commands list-destinations: Lists the available destinations in the broker. publish-file: Publishes the file to the given destination. publish-string: Publishes the value to the given destination. Built-In Commands clear: Clear the shell screen. exit, quit: Exit the shell. help: Display help about available commands. script: Read and execute commands from a file. stacktrace: Display the full stacktrace of the last error. Database Commands delete-database: Deletes a database list-databases: Lists the available databases. start-database: Starts a database. stop-database: Stops a database. Endpoint Commands delete-endpoint: Deletes an endpoint. disable-endpoint: Disables an endpoint. enable-endpoint: Enables an endpoint. list-endpoints: Lists the endpoints for a given package. start-endpoint: Starts an endpoint. stop-endpoint: Stops an endpoint. License Commands export-license: Exports the currently installed license in this machine to a file. import-license: Imports a license from the provided file to this machine. install-license: Installs a license to this machine. license: Prints the currently installed license in this machine. product-key: Prints the product key for the installation in this machine. sync-license: Syncs the currently installed license in this machine. Package Commands create-package: Creates an empty package. delete-package: Deletes a package. deploy-package: Deploys a package to a target server. download-package: Downloads a package. list-packages: Lists the installed packages. start-package: Starts a package. stop-package: Stops a package. upload-packages: Uploads packages. Properties Commands delete-properties: Deletes properties that match the provided keys. export-properties: Exports the properties from the application into a file import-properties: Imports the properties from the provided file. list-properties: Lists the application properties. save-properties: Saves the provided properties to the application. Remote Server Commands find-server: Find a registered remote server by name. list-servers: List registered remote servers. register-server: Register a remote server for the current instance to take note of. unregister-server: Unregister a remote server. System Commands head: Prints the head of a log on a specified date logs: Download logs on a specified date, up to the present restart: Restarts the application. shutdown: Shuts down the application. tail: Prints the tail of a log on a specified date
Managing an instance
As of this writing, the CLI supports commands for managing the following features (type
- Remote server
Using the CLI tool to deploy packages
Martini packages can be deployed between instances over different servers. This can be done via the CLI tool using
http://localhost:8080 > deploy-packages remote-server.site:8080 package-to-deploy --username firstname.lastname@example.org --password password --auto-start Deploying [package-to-deploy] to [remote-server.site:8080]... Deployed.
Displaying help text
To get hints on any command, just type
help followed by the intended command.
1 2 3 4 5 6 7 8 9 10 11 12 13
http://localhost:8080 > help start-package NAME start-package - Starts a package. SYNOPSYS start-package [--name] string OPTIONS --name string Name of the package to start. [Mandatory]
The CLI supports autocompletion. By typing
list- for example, the CLI will display matching commands
that start with
1 2 3 4 5 6 7 8
http://localhost:8080 > list- Available commands list-databases (Lists the available databases.) list-destinations (Lists the available destinations in the broker.) list-endpoints (Lists the endpoints for a given package.) list-packages (Lists the installed packages.) list-properties (Lists the application properties.) list-servers (List registered remote servers.)
You may press again to choose a command from the selection.
1 2 3 4 5 6 7
http://localhost:8080 > list-packages ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓ ┃Name ┃Context Path┃Status ┃State on Startup┃Version ┃ ┣━━━━━━━━╋━━━━━━━━━━━━╋━━━━━━━╋━━━━━━━━━━━━━━━━╋━━━━━━━━━━┫ ┃examples┃/examples ┃STARTED┃STARTED ┃1 ┃ ┃core ┃ ┃STARTED┃STARTED ┃1.0.0 ┃ ┗━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━┻━━━━━━━━━━━━━━━━┻━━━━━━━━━━┛
When in doubt, out
The CLI aims to be as ergonomic as possible. For example, typing
http://localhost:8080 > stop-package --name core examples
Reverse search is a terminal feature that allows users to easily find and execute previously typed commands. You can do this with the CLI as well by pressing .
For example, by typing
co then pressing the CLI will suggest the previous command we
used to connect:
> connect --uri http://localhost:8080 --username email@example.com --password password bck-i-search: co_
You can press repeatedly to cycle through multiple matching commands.
All commands typed during the shell session are written to a log file named
under the same directory where the CLI was launched. This is reused by the tool for reverse searches. Make sure that
the log file is not publicly accessible.
Automation is king! You can write scripts that contain a series of commands that need to be executed sequentially by the CLI.
For example, consider this script file named
stop-packages.esb, that stops a list of packages:
1 2 3 4 5 6
connect --uri http://localhost:8080 --username firstname.lastname@example.org --password password stop-package --name examples-messaging stop-package --name examples-reports stop-package --name examples-services list-packages exit
Passing that as arguments to the CLI in the form of:
$ java -jar martini-cli-client.jar @stop-packages.esb