clc script run
Runs the script in the given location.
Runs the given script.
Two kinds of scripts are supported:
-
Shell scripts: CLC commands or SQL
-
Advanced scripts: a Python-like language
The scripts may be in the following location:
-
Filesystem path: The path may optionally have the file:// prefix.
Shell Script
The script can contain:
-
SQL statements
-
CLC commands prefixed with backslash.
-
Comments starting with
--
(double dash)
The script should have either .clc
or .sql
extension.
Files with one of these two extensions are interpreted equivalently.
Advanced Script (BETA)
Advanced scripts are written in a Python-like language called Starlark. See this document for the language reference: https://github.com/google/starlark-go/blob/master/doc/spec.md
CLC commands are mapped to functions using a few straightforward rules:
-
If the command is a top level command, it is mapped as is. E.g.,
home
command is mapped to thehome()
function. -
Positional arguments are mapped to positional arguments in the function signature.
-
Flags are mapped to keyword arguments in the function signature.
Examples:
-
clc map set -n mymap foo bar
⇒map_set("foo", "bar", name="mymap")
The script should have the .star extension. Only the filesystem is supported as a source for advanced scripts.
The following values are available for advanced scripts:
Value | Description |
---|---|
|
1 nanoscond. |
|
1 microsecond in nanoseconds. |
|
1 millisecond in nanoseconds. |
|
1 second in nanoseconds. |
|
1 minute in nanoseconds. |
|
1 hour in nanoseconds. |
|
1 day in nanoseconds. |
The following functions are available for advanced scripts:
Function | Description |
---|---|
|
Returns the arguments passed to the script as a list. 0th item in the list is the script name. |
|
Returns the type name of the given data value. |
|
Attempts to convert the data value to the corresponding script value. |
|
Returns the last error or |
|
Adds a DEBUG message to the CLC log. |
|
Adds an ERROR message to the CLC log. You can pass a |
|
Adds a WARN message to the CLC log. |
|
Clears the given Map. |
|
Deletes the given Map. |
|
Returns a list of tuples that has the key in index 0 and the value in index 1. Keys and values are `data_value`s. |
|
|
|
Returns the |
|
Returns a list of keys as |
|
Locks a key in the Map. |
|
Loads the given keys or all keys in the MapStore if no key was specifed. |
|
Deletes the given key from the Map and returns the corresponding value. |
|
Sets the given value for the given key. |
|
Returns the size of the Map. |
|
Attempts to lock the entry for the given key. Returns |
|
Unlocks the entry for the given key. |
|
Returns the values in the Map as a list. |
|
Sets the value for the given key if it has the expected value. |
|
Deletes the value of a given key in a CPMap. |
|
Deletes the CPMap and all the data in it. |
|
Gets a value from the given CPMap. |
|
Puts the given value in the given CPMap and returns the old value. |
|
Removes the value of a given key in a CPMap and returns the old value. |
|
Sets a value in the given CPMap. |
|
Returns the current time in nanoseconds. |
|
Returns the data structure objects in the |
|
Sleeps for the given nanoseconds. For example, to sleep for 10 seconds: |
Usage:
clc script run [path/location] [flags] -- [parameter, ...]
Parameters:
Parameter | Required | Description | Default |
---|---|---|---|
|
Optional |
Arguments to be passed to an advanced script. The arguments can be retrieved using the |
|
|
Optional |
Print the executed command. Not used in advanced script. |
|
|
Optional |
Ignore errors during script execution |
|
|
Optional |
Enable the debug mode for advanced scripts. |
|
Global parameters
Parameter | Description | Default | ||
---|---|---|---|---|
|
Path to the configuration file in YAML format. |
The following locations are tried in order for the existence of
|
||
|
Set the output format
|
|
||
|
Set the log level, one of:
|
|
||
|
Set the log path. Use |
|
||
|
Prevent displaying unnecessary output. |
|
||
|
Enable output with more information. |
|
||
|
Timeout for operation to complete. The duration is a string in the form of
Underscore (_) character is ignored in the The following are a few of the valid DURATIONs:
|