Skip to content

CLI

Comet Blitzen Prancer

This runtime provides the ability to access the language/runner via a Command Line Interface (CLI). It includes the following functionality:

  • Execute a given solution's source file, providing benchmark timing for each defined part.
  • Execute a given solutions source files test suite.
  • Execute a given script source file.
  • (Comet only) Load an interactive REPL environment, which can be used to quickly explore the language.

Release (Comet)

Platform Release
Linux (x64) santa-lang-comet-cli-0.0.13-linux-amd64
Linux (ARM) santa-lang-comet-cli-0.0.13-linux-arm64
macOS (Intel) santa-lang-comet-cli-0.0.13-macos-amd64
macOS (ARM) santa-lang-comet-cli-0.0.13-macos-arm64
Docker ghcr.io/eddmann/santa-lang-cli:latest

Note: Blitzen and Prancer CLIs can be accessed via their GitHub repositories: Blitzen, Prancer.

The macOS release may require you to remove the quarantine flag from the executable: xattr -d com.apple.quarantine santa-lang-comet-cli-*

External Functions

The CLI provides three runtime specific functions, these are:

puts

puts(..value)

Prints the supplied values (using their display format) to stdout.

puts("Hello", [1, 2.5, true])

read

read(path)

Reads the contents of the given path into a String. The path can either be:

  • A local directory path, absolute or relative to the source file.
  • Based on a http(s) schema being defined; a web URL location.
  • Based on a aoc schema being defined; a specific Advent of Code problem input (i.e. aoc://2015/1). In this case an external SANTA_CLI_SESSION_TOKEN environment variable must be defined which includes a valid Advent of Code session token. This can be extracted from the cookie set upon successful login to the platform.
read("input.txt")
read("https://www.example.com/input.txt")
read("aoc://2015/1")

env

env()

(REPL only) Prints the current environment's variables

Formatting

Comet

The CLI provides an opinionated code formatter that produces consistent, readable output. There are no configuration options - it enforces a single canonical style.

# Format to stdout
santa-cli -f solution.santa

# Format file in place
santa-cli --fmt-write solution.santa

# Check if formatted (exit 1 if not, useful for CI)
santa-cli --fmt-check solution.santa

The formatter also accepts input from stdin or inline expressions:

# Format from stdin
echo "let x=1+2" | santa-cli -f

# Format inline expression
santa-cli -e "let x=1+2" -f

See the Formatter documentation for details on formatting rules.

Errors

If an error occurrs during execution the the program is immediately halted; with the error message and associated call stack trace presented to the user, as shown below:

CLI Errors

Profiling

Comet's CLI can be built locally (via a Cargo profile feature flag) with additional flamegraph/pprof CPU profiling output for a given solutions' execution. This can be useful when trying to determine slow areas of a given solution, to improve its overall performance.

CLI Profiler

Example

Below is example output for a successful Advent of Code solution and test execution, using the AoC runner:

CLI Runner

Below is example usage of the in-built CLI REPL environment:

CLI REPL