fbpx

faastRuby CLI Reference

faastRuby CLI Reference

The faastRuby CLI allows users to manage Projects, Workspaces and Functions hosted at the faastRuby Cloud Platform.

Syntax

faastruby [OPTIONS] COMMAND [-h,--help] [ARGS]

Options

-h, --help, help

Displays the main help.

-v

Print version and exit.

--region tor1

Specify a faastRuby Cloud region. The region tor1 is the only one available at this moment.


Commands

The commands are divided in 4 categories: Accounts, Projects, Workspaces and Functions.

Accounts

You can use the command line to perform account-related tasks like signup, login and logout.

confirm-account

Send a token over email for account confirmation.

Usage:

$ faastruby confirm-account --email youremail@example.com

login

Login and store API credentials in the current machine.

Usage:

$ faastruby login
Email: email@example.com
Password: 
Login successful.

You can also pass the email and password via command line. Example:

$ faastruby login --email $EMAIL --password $PASSWORD

logout

Invalidate the API credentials in the current machine and remove them from disk.

Usage:

$ faastruby logout

You can also invalidate all existing API credentials. This will force logout on every machine you might be logged in.

$ faastruby logout --all

signup

Create an account on the faastRuby Cloud Platform.

Usage:

$ faastruby signup

Functions

deploy-to

Login required.

Deploy a function to a cloud workspace. If the workspace doesn't exist, the tool will attempt to create it.

Usage:

$ faastruby deploy-to WORKSPACE_NAME [ARGS]

Arguments:

  • --dont-create-workspace
    • Don't try to create the workspace if it doesn't exist.
  • -f, --function path/to/function
    • Specify the directory where the function is. Defaults to the current directory.
  • --context 'json_string'
    • The data to be encrypted and stored as execution context in the cloud, accessible via event.context from within your function. You might need to wrap it in single quotes.
    • The context data must be a valid JSON string, and have maximum size of 4KB.
  • --set-root
    • Set the function as the root route for the workspace.
  • --set-catch-all
    • Set the function as the catch-all route for the workspace.
  • --context-from-stdin
    • Read context data from STDIN.

new

Initialize a directory with a function template.

Usage:

$ faastruby new FUNCTION_NAME [ARGS]

Arguments:

  • --blank
    • Create a function using a blank template.
  • --force
    • Overwrite files if directory already exists.
  • -g, --git
    • Initialize a git repository
  • --runtime
    • Specify a language runtime.
    • To view the supported runtimes, run faastruby new --help
  • --template TYPE(local|git|github):SOURCE
    • Initialize a function using a template from a local disk path or a git repository.
    • Examples:
      • --template local:/path/to/folder
      • --template git:git@github.com:user/repo.git
      • --template github:user/repo

remove-from

Remove a function from a cloud workspace.

Usage:

$ faastruby remove-from WORKSPACE_NAME [ARGS]

Arguments:

  • -y, --yes
    • Don't prompt for confirmation.
  • -f, --function FUNCTION_NAME
    • Pass the function name instead of attempting to read from the function's config file.

run

Trigger a function via its HTTP endpoint.

Usage:

$ faastruby run WORKSPACE_NAME [ARGS]

Arguments:

  • -b, --body data
    • The request body.
  • --stdin
    • Read the request body from STDIN.
  • -m, --method GET | POST | PUT | PATCH | DELETE
    • Set the request method.
  • -h, --header 'Header: Value'
    • Set a header.
    • Can be used multiple times.
  • -f, --form 'param1=value1&param2=value2'
    • Send body as form data and set header 'Content-Type: application/x-www-form-urlencoded'.
  • -j, --json json_string
    • Send body as JSON data and set header 'Content-Type: application/json'.
  • --measure
    • Return function execution time in the response headers.
  • -q, --query 'param=value'
    • Set a query parameter for the request.
    • Can be used multiple times.
  • --curl
    • Print the equivalent CURL command for the request and exit.

update-context

Update the context data for a function.

Usage:

$ faastruby update-context WORKSPACE_NAME [ARGS]

Arguments:

  • -d, --data 'json_string'
    • The data to be encrypted and stored as execution context in the cloud, accessible via event.context from within your function. You might need to wrap it in single quotes.
    • The context data must be a valid JSON string, and have maximum size of 4KB.
  • --stdin
    • Read context data from STDIN.

Projects

deploy

Deploy functions and static assets that belong to a given project to a cloud workspace. This command must be executed from within the project's directory.

Usage:

$ faastruby deploy [ARGS]

Arguments:

  • -f, --function path/to/function
    • Specify the path to the function directory in your local machine.
    • This argument can be repeated many times for multiple functions:
      • -f path/to/function1 -f path/to/function2
  • -e, --env environment
    • Environment is added to the project's name to compose the workspace name.

down

Remove a workspace from the cloud. Must be executed from within a project's directory.

Usage:

$ faastruby down [ARGS]

Arguments:

  • -e, --env environment
    • Environment is added to the project's name to compose the workspace name.

new-project

Create a directory on the current path and initialize a project.

Usage:

$ faastruby new-project PROJECT_NAME [ARGS]

Arguments:

  • --api
    • Initialize a project folder using an API template
  • --web
    • (Default) Initialize a project folder using a WEB template

Workspaces

cp

Copy a static file from your local machine to a cloud workspace.

Usage:

$ faastruby cp SOURCE_FILE WORKSPACE_NAME:/DESTINATION/PATH

Example:

$ faastruby cp public/robots.txt myproject-stage-abc123:/robots.txt

create-workspace

Create a cloud workspace.

Usage:

$ faastruby create-workspace WORKSPACE_NAME [ARGS]

Arguments:

  • --create-local-dir
    • Create a local directory with the workspace name.

destroy-workspace

Remove a workspace and all its functions from the cloud. This operation can't be undone.

Usage:

$ faastruby destroy-workspace WORKSPACE_NAME [ARGS]

Arguments:

  • -y, --yes
    • Don't prompt for confirmation.

list-workspace

List the contents of a cloud workspace.

Usage:

$ faastruby list-workspace WORKSPACE_NAME

rm

Remove static file from cloud workspace path /destination/path.

Usage:

$ faastruby rm WORKSPACE_NAME:/DESTINATION/PATH

Example:

$ faastruby rm myproject-stage-abc123:/robots.txt

update-workspace

Update workspace settings.

Usage:

$ faastruby update-workspace WORKSPACE_NAME ARGS

Arguments:

  • --runners N
    • Assign N runners to the workspace.
    • N must be an integer between 0 and 100.
    • When set to 0, requests to any functions within the workspace will return HTTP error 429 - Too Many Requests.

Output of faastruby help

faastRuby CLI - Manage workspaces and functions hosted at faastruby.io
Version: 0.5.15

Usage: faastruby [update] [OPTIONS] COMMAND [--help | -h] [ARGS]

To update to the latest version, run: faastruby update

OPTIONS:
  help, -h, --help     # Displays this help
  -v                   # Print version and exit
  --region tor1        # Specify a region. "tor1" (default) is the only
                       #  region available at this time

COMMANDS:

Accounts:
  signup
  confirm-account      # Send a token over email for account confirmation
  login
  logout

Functions:
  new                  # Initialize a function in your local machine
  deploy-to            # Deploy a function to a cloud workspace
  remove-from          # Remove a function from a cloud workspace
  run                  # Trigger the function via HTTP endpoint
  update-context       # Update the context data for a function

Projects:
  new-project          # Initialize a project in your local machine
  deploy               # Deploy all functions and static files of a project
  down                 # Remove a workspace from the cloud. Must be executed
                       #  from within a project directory.

Workspaces:
  create-workspace     # Create a cloud workspace
  destroy-workspace    # Erase a workspace from the cloud
  list-workspace       # List what's in a cloud workspace
  cp                   # Copy a static file from your local machine to
                       #  a cloud workspace
  rm                   # Remove a static file from a cloud workspace
  update-workspace     # Update workspace settings

Run faastruby COMMAND --help for more details.