There are several ways to get started with the CloudSlang CLI.
Prerequisites : To run the CloudSlang CLI, Java JRE version 7 or higher is required.
- Download the CLI with content zip file.
- Locate the downloaded file and unzip the archive.
The decompressed file contains:
- A folder named cslang-cli with the CLI tool and its necessary dependencies.
- A folder named content with ready-made CloudSlang flows and operations.
- A folder named python-lib.
- Navigate to the folder
cslang-cli\bin\
. - Run the executable:
- For Windows :
cslang.bat
. - For Linux :
bash cslang
.
- For Windows :
Prerequisites : To build the CloudSlang CLI, Java JDK version 7 or higher and Maven version 3.0.3 or higher are required.
- Git clone (or GitHub fork and then clone) the source code.
- Using the Command Prompt, navigate to the project root directory.
- Build the project by running
mvn clean install
. - After the build finishes, navigate to the
cloudslang-cli\target\cloudslang\bin
folder. - Run the executable:
- For Windows :
cslang.bat
. - For Linux :
bash cslang
.
- For Windows :
Prerequisites : To download the package, Node.js is required. To run the CloudSlang CLI, Java JRE version 7 or higher is required.
- At a command prompt, enter
npm install -g cloudslang-cli
.- If using Linux, the sudo command might be neccessary:
sudo npm install -g cloudslang-cli
.
- If using Linux, the sudo command might be neccessary:
- Enter the
cslang
command at any command prompt.
There are two CloudSlang Docker images. One (cloudslang/cloudslang) is a lightweight image meant to get you running CloudSlang flows as quickly as possible. The other image (cloudslang/cloudslang-dev) adds the tools necessary to develop CloudSlang flows.
This image includes:
- Java
- CloudSlang CLI
- CloudSlang content
To get the image: docker pull cloudslang/cloudslang
To run a flow with a CloudSlang prompt:
docker run -it cloudslang/cloudslang
- At the prompt enter:
run --f ../content/io/cloudslang/.../flow.sl --i input1=value1
Or, to run the flow without the prompt:
docker run --rm cloudslang/cloudslang run --f ../content/io/cloudslang/.../flow.sl --i input1=value1
This image includes:
- Java
- CloudSlang CLI
- CloudSlang content
- Python
- Pip
- Vim
- Emacs
- SSH
- Git
- Atom
- language-cloudslang Atom package
To get the image: docker pull cloudslang/cloudslang-dev
The CLI can be configured using the configuration file found at
cslang-cli/configuration/cslang.properties
.
Some of the configuration items are listed in the table below:
Configuration key | Default value | Description |
---|---|---|
log4j.configuration | file:${app.home}/configuration/logging/log4j.properties | Location of logging
configuration file
|
cslang.encoding | utf-8 | Character encoding
for input values
and input files
|
maven.home | ${app.home}/maven/apache-maven-x.y.z | Location of CloudSlang
Maven repository home
directory
|
maven.settings.xml.path | ${app.home}/maven/conf/settings.xml | Location of
Maven settings file
|
cloudslang.maven.repo.local | ${app.home}/maven/repo | Location of local
repository
|
cloudslang.maven.repo.remote.url | http://repo1.maven.org/maven2 | Location of remote
Maven repository
|
cloudslang.maven.plugins.remote.url | http://repo1.maven.org/maven2 | Location of remote
Maven plugins
|
The CLI's logging can be configured using the logging configuration file. The location of the logging configuration file is defined in the :ref:`CLI's configuration file <configure_cli>`.
The CLI uses Maven to manage Java action dependencies. There are several
Maven configuration properties found in the :ref:`CLI's
configuration file <configure_cli>`. To configure Maven to use a remote
repository other than Maven Central, edit the values for
cloudslang.maven.repo.remote.url
and cloudslang.maven.plugins.remote.url
.
Additionally, you can edit the proxy settings in the file found
at maven.settings.xml.path
.
When a flow is run, the entire directory in which the flow resides is
scanned recursively (including all subfolders) for files with a valid
CloudSlang extension. All of the files found are compiled by the CLI. If
the --cp
flag is used, all of the directories listed there will be
scanned and compiled recursively as well.
Note
Use forward slashes (/
) in all file paths, even on Windows, because
back slashes (\
) can be interpreted as special characters.
To run a flow or operation located at c:/.../your_flow.sl
, use the
--f
flag to specify the location of the flow to be run:
cslang>run --f c:/.../your_flow.sl
If the flow or operation takes in input parameters, use the --i
flag
and a comma-separated list of key=value pairs:
cslang>run --f c:/.../your_flow.sl --i input1=root,input2=25
Commas (,
) can be used as part of input values by escaping them with
a backslash (\
).
cslang>run --f c:/.../your_flow.sl --i list=1\,2\,3
To use inputs that include spaces, enclose the entire input list in
quotes ("
):
cslang>run --f c:/.../your_flow.sl --i "input1=Hello World, input2=x"
Double quotes ("
) can be used as part of quoted input values by
escaping them with a backslash (\
). When using a quoted input list,
spaces between input parameters will be trimmed.
To pass the value "Hello" World to a flow:
cslang>run --f c:/.../your_flow.sl --i "input1=\"Hello\" World"
Alternatively, inputs made be loaded from a file. Inputs files are written in flat YAML, containing a map of names to values. Inputs files end with the .yaml or .yml extensions. It is a best practice for the name of an inputs file to end with .inputs.yaml. If multiple inputs files are being used and they contain an input with the same name, the input in the file that is loaded last will overwrite the others with the same name.
Inputs files can be loaded automatically if placed in a folder located at
cslang-cli/configuration/inputs
. If the flow requires an inputs file that is not
loaded automatically, use the --if
flag and a comma-separated list of file
paths. Inputs passed with the --i
flag will override the inputs passed using
a file.
Example - same inputs passed to flow using command line and inputs file
Inputs passed from the command line - run command
cslang>run --f C:/.../your_flow.sl --i "input1=simple text,input2=comma\, text,input3=\"quoted text\""
Inputs passed using an inputs file - run command
cslang>run --f C:/.../your_flow.sl --if C:/.../inputs.yaml
Inputs passed using an inputs file - inputs.yaml file
input1: simple text
input2: comma, text
input3: '"quoted text"'
Example - complex inputs file
input: hello
input_list:
- one
- two
- three
input_map:
one: a
two: b
three: c
If the flow requires dependencies they can be added to the classpath using the
--cp
flag with a comma-separated list of dependency paths. If no cp
flag
is present, the cslang-cli/content folder is added to the classpath by default.
If there is no --cp
flag and no cslang-cli/content folder, the running flow
or operation's folder is added to the classpath by default.
cslang>run --f c:/.../your_flow.sl --i input1=root,input2=25 --cp c:/.../yaml
A system properties file is a type of CloudSlang file that contains a list of system property keys and values. If multiple system properties files are being used and they contain a system property with the same fully qualified name, the property in the file that is loaded last will overwrite the others with the same name.
System property names (keys) can contain alphanumeric characters (A-Za-z0-9), underscores (_) and hyphens (-). For more information on the structure of system properties files see the :ref:`CloudSlang Files <cloudslang_files>` and :ref:`properties <properties>` sections of the DSL Reference.
System property files can be loaded automatically if placed in a folder or
subfolder within cslang-cli/configuration/properties
. If the flow or operation
requires a system properties file that is not loaded automatically, use the
--spf
flag and a comma-separated list of file paths.
cslang>run --f c:/.../your_flow.sl --spf c:/.../yaml
Example - system properties file
namespace: examples.sysprops
properties:
- host: 'localhost'
- port: 8080
Note
System property values that are non-string types (numeric, list, map,
etc.) are converted to string representations. A system property may have a
value of null
.
An empty system properties file can be defined using an empty list.
Example: empty system properties file
namespace: examples.sysprops
properties: []
A flow can be run without first starting up the CLI using the non-interactive mode.
From a shell prompt:
Windows
>cslang.bat run --f c:/.../your_flow.sl
Linux
>cslang run --f c:/.../your_flow.sl
The CLI can run flows and operations at several levels of verbosity.
To change the verbosity level, use the --v
flag.
Verbosity level | Printed to the screen | Syntax |
---|---|---|
default |
step names and top-level outputs | no flag or --v default |
quiet |
top-level outputs | --v quiet |
debug |
default + each step's published variables | --v or --v debug |
Run in quiet mode:
cslang>run --f c:/.../your_flow.sl --v quiet
Run in debug mode:
cslang>run --f c:/.../your_flow.sl --v
To view a flow or operation's description, inputs, outputs and results use the
inspect
command.
cslang>inspect c:/.../your_flow.sl
To list the properties contained in a system properties file use the list
command.
cslang>list c:/.../your_properties.prop.sl
Some of the available commands are:
env --setAsync
- Sets the execution mode to be synchronous (false
) or asynchronous (true
). By default the execution mode is synchronous, meaning only one flow can run at a time.
cslang>env --setAsync true
inputs
- Lists the inputs of a given flow.
cslang>inputs --f c:/.../your_flow.sl
cslang --version
- Displays the version of the CLI being used.
cslang>cslang --version
The execution log is saved at cslang-cli/logs/execution.log
. The log file stores
all the :ref:`events <slang_events>` that have been fired, and
therefore allows for tracking a flow's execution.
Log files of Maven activity are saved at cslang-cli/logs/maven/
. Each artifact's
activity is stored in a file named with the convention
<group>_<artifact>_<version>.log
.
The CLI history is saved at cslang-cli/cslang-cli.history
.
To get a list of available commands, enter help
at the CLI
cslang>
prompt. For further help, enter help
and the name of the
command.