How to use the function command in the Scale CLI.
function
command is used to interact with Scale Functions locally. fn
is an alias for function
.
scale new
command is an alias for scale function new
. You can use either command to login to the Scale API.--language
flag:
go
- Gorust
- Rustts
- TypeScript/JavaScript#scale
channel in our Discord.build
subcommand is used to build a Scale Function using the toolchain for the Scale Function’s source language. It can be
run from the root of the Scale Function’s directory:
--directory
flag can be used to specify the directory of the Scale Function:
--name
, --org
, and --tag
flags can be used to specify the name, organization, and tag of the Scale Function at build time:
--cargo
, --go
, and --tinygo
flags can be used to specify the path to the cargo
, go
, and tinygo
executables.
list
subcommand is used to list all the compiled Scale Functions available in the local Scale Function cache.
--cache-directory
flag:
run
subcommand. This command will start a local HTTP server that will
execute the Scale Function when it receives an HTTP request.
--listen
flag can be used to specify the address and port that the local HTTP server should listen on (by default it will listen on :8080
)
It is also possible to provide multiple Scale Functions to the run
subcommand. If you do, the local HTTP server will execute the
Scale Functions in a chain, and will only execute the next function in the chain if the previous function calls .Next()
.
--cache-directory
configuration flag can be used to specify the directory of the Scale Function cache.run
command will attempt to look for it in the Scale Registry (if the CLI is authenticated).
export
subcommand is used to export a Scale Function from the local Scale Function cache to a local .scale
file.
It’s helpful in situations where you want to distribute a Scale Function without using the Scale Registry, or
if you want to embed it inside your Runtime or Application.
<path>
directory as a .scale
file. The --output
flag can be used to override
the name of the exported .scale
file:
--raw
flag can be used to export the raw WebAssembly .wasm
binary instead of the .scale
file: