|IMPORTANT: This functionality is "General Available" as of release 3.12.|
The Sweagle command-line interface (CLI) simplifies the REST API integration with Sweagle for the most common tasks. The CLI is a small, standalone package that encapsulates the most commonly used Sweagle REST API methods into an "easier to use" syntax directly from the command line.
Compared to the REST API, the CLI offers capabilities that are a sequence of various API calls. As an example when using the uploadData option, the CLI will :
- open a data changeset
- upload the data from the provided source (in this case the CDI "myCounter" with value 5 in format type "properties") to a path in the data model (in this case baseData, settings)
- approve the data changeset and create a snapshot for each of the impacted CDS
./sweagle uploadData -as -n baseData,uid -t props -d "myCounter=5"
For tech-savvy users, the Sweagle CLI can be a way to perform some of the user tasks directly from the terminal. But it can also be used in external scripts and process automation tools as a simplified syntax to automate tasks for uploading, validating, and consuming configuration data in the Sweagle platform.
The Sweagle CLI is a standalone package and there is no third-party installation required.
The package is available for recent versions of MS Windows, *NIX, and macOS. Login to your Sweagle environment and download the package for your operating system from the help menu (top right corner).
After download, copy that file to the folder from where you want to run the Sweagle CLI. Also, for Linux and macOS, give the Sweagle file execution permissions (chmod +x sweagle)
a. API token
The Sweagle CLI requires a valid API user to connect and allow (some of) the commands and actions on your data model. Copy the API token from one of the API users that are connected to your profile. In case you have no assigned API users, contact a user administrator who can set up an API user and assign it to your personal user details.
Run the one-time setup command (
./sweagle setup) from the folder from where you want to run the Sweagle CLI. Follow the guided questions. Note that the GitHub integration is optional.
Tip: Use the "secure store of tokens" option as it will encrypt your API token and other passwords required for CLI.
c. Sanity Check
You can check that the Sweagle CLI is properly running and can reach your Sweagle environment by using the
./sweagle info command
d. Update Sweagle CLI
There is a built-in function for the Sweagle CLI to check for a new version of the CLI from the Sweagle environment, download it and replace the package with the new version.
How to use the CLI
There are 2 ways to use the Sweagle CLI
- directly through the terminal and entering commands
- starting in interactive mode
1 - Direct Through Terminal
Execute commands directly from the command line. Note that the commands are case sensitive. There is a basic help function available for each of the commands at any level in the options using -h or --help.
Sweagle CLI command argument flags follow the git syntax. That means that multiple flags can be added in a short notation format. As an example, the uploadData command where you want to set the flags autoApprove=true and storeSnapshotResults=true can be done by adding "-as" to the terminal command.
./sweagle uploadData -as ....
2 - Interactive Mode
Start the interactive mode through the command
./sweagle start. This provides an interactive menu in which the user can navigate using the up and down arrow, select commands, enter filters, and use the results.
When a command has been fully configured through the interactive menu and the result is on the terminal you can choose the option to "show the CURL command" or "show the CLI command" which you can copy-paste for your scripts and automation. In this way, the interactive mode is an easy way to compose your Sweagle CLI commands without having to read through the help information on how to use them.