Using the CLI Tools
Learn all the command line interface (CLI) commands need to get started, build, test and run programs, work with Ballerina Central, and manage projects.
ballerina, cli, command line interface, programming language
The Ballerina Tool is your one-stop-shop for all the things you do in Ballerina.
Using the Ballerina Tool
In the CLI, execute the
ballerina help command to view all the actions you can perform with it as shown below.
→ ballerina help NAME The Ballerina build tool SYNOPSIS ballerina <-v | --version> ballerina [command] <-h | --help> ballerina <command> [<args>] DESCRIPTION Ballerina is a statically typed, concurrent programming language, focusing on network interaction and structured data. It is intended to be the core of a language-centric middleware platform. It has all the general-purpose functionality expected of a modern programming language, but it also has several unusual aspects that make it particularly suitable for its intended purpose. Find more information at: https://ballerina.io/ OPTIONS -v, --version Print the Ballerina version information. -h, --help Print usage details of a command. BALLERINA COMMANDS Here is a list of available subcommands: Core Commands: build Compile Ballerina program into an executable run Build and run Ballerina program test Run module tests doc Generate API documentation clean Clean artifacts generated during the build format Format Ballerina sources Module Commands: pull Pull a module from Ballerina Central push Upload module to the Ballerina Central search Search Ballerina Central for modules Project Commands: new Create a new Ballerina project add Create a new Ballerina module in a project Other Commands: encrypt Encrypt sensitive data grpc Generate Ballerina sources for the given protobuf definition openapi Generate Ballerina sources for the given OpenAPI definition and vice versa. version Print Ballerina version bindgen Generate Ballerina bindings for Java APIs Update Commands: dist Manage Ballerina distributions update Update the Ballerina Tool Use 'ballerina help <command>' for more information on a specific command.
You can use the
ballerina command in the below format.
ballerina <THE-COMMAND> <ITS-ARGUEMENTS>
Tip: You can view details of any of the commands below by executing
ballerina help <COMMAND>. For example, the below is the output of the
ballerina help pullcommand.
→ ballerina help pull NAME ballerina-pull - Fetch modules from Ballerina Central SYNOPSIS ballerina pull <org-name>/<module-name>[:<version>] DESCRIPTION Pull downloads the specified module from Ballerina Central along with its dependencies. It then caches this module at '.ballerina' directory in user home. Ballerina Central is a module repository hosted at https://central.ballerina.io/. A module repository organizes modules into a three-level hierarchy: organization, module name, and version. Organizations are unique within a repository and can be mapped to an individual user or organization registered with the repository. EXAMPLES Pull the latest version of 'gmail' connector in 'wso2' organization from Ballerina Central. $ ballerina pull wso2/gmail Pull the '1.1.0' version of 'gmail' connector in 'wso2' organization from Ballerina Central. $ ballerina pull wso2/gmail:1.1.0
These everyday commands are your best friends! They address the very basics of programming in Ballerina such as compiling, running, testing programs, and generating their documentation.
|build||Compile a Ballerina program, a single BAL file, an entire project, or a single root module into an executable JAR file.|
|run||Build and run a Ballerina program, a single BAL file, a module, an entire project, or a previously-built program. For more information, see Running Ballerina Code.|
|test||Run tests of a particular module or all the modules of a Ballerina project. For more information, see Testing Ballerina Code.|
|doc||Generate API documents for all public symbols of a Ballerina module or project. For more information, see Documenting Ballerina Code.|
|clean||Clean all artifacts generated by the build command for a project.|
|format||Format Ballerina source files as per the Coding Conventions.|
These commands allow you to work with the Ballerina Central to share Ballerina modules with others in a safe, secure, and dependable way.
|pull||Pull a module from Ballerina Central.|
|push||Upload a module to Ballerina Central. For more information, see Publishing Modules to Ballerina Central.|
|search||Search Ballerina Central for modules.|
Ballerina projects are the way to organize real-world Ballerina development tasks.
|new||Create a Ballerina project. For more information, see Structuring Ballerina Code.|
|add||Create a new Ballerina module in a project. For more information, see Structuring Ballerina Code.|
These powerful supporting tools extend Ballerina to various ecosystem technologies that are inherently cloud-native. This functionality will grow over time and will even be developer extensible in the future.
|encrypt||Use this tool to encrypt sensitive data and pass them to a Ballerina program via the configuration system.|
|grpc||This is the gRPC stub/skeleton generation tool. For more information, see Generating Ballerina Code for Protocol Buffer Definitions.|
|openapi||This is the OpenAPI (Swagger) stub/skeleton generation tool. For more information, see Using the OpenAPI Tools.|
|version||Tells you the version of the distribution you are currently using, the language specification version on which it is based, and the update tool version, which is currently in use.|
|bindgen||Use this tool for auto-generating Ballerina bridge code for Java APIs. For more information, see Calling Java Code from Ballerina.|
|help||Prints the usage details of any Ballerina command (e.g., `ballerina help pull`).|
|dist||Manage Ballerina distributions. For more information, see Keeping Ballerina Up to Date.|
|update||Update the Ballerina Tool. For more information, see Keeping Ballerina Up to Date.|