# CLI

Source: https://docs.formance.com/v4.0/modules/numscript/cli

Stack: v4.0

## Install

You can install the `numscript` CLI in one of the following ways:

#### Using curl

For Mac and Unix:

```sh
curl -sSf https://raw.githubusercontent.com/formancehq/numscript/main/install.sh | bash
```

#### Using golang toolchain

```sh
go install github.com/formancehq/numscript/cmd/numscript@latest
```

## Check

You can use the `numscript check`  command to run static analysis on a numscript program.  The static analysis includes parsing errors, wrong variables or types usage, as well as more advanced checks on numscript constructs.

You can use it this way:

```shellscript
numscript check my-file.num
```

The command will exit with an error status code if there is at least one error or warning.

## Run

Available from numscript\@0.0.19

You can use the CLI to run local scripts (mostly intended for local prototyping).

For example, given this script:

```numscript my-script.num
vars {
  monetary $amt  
}

send $amt (
  source = @alice
  destination = @world
)
```

And this inputs file (which has to have the same name as the numscript file, plus the `.inputs.json` suffix):

```json my-script.num.inputs.json
{
  "$schema": "https://raw.githubusercontent.com/formancehq/numscript/refs/heads/main/v1.inputs.schema.json",
  "variables": {
    "amt": "USD/2 100"
  },
  "balances": [
    { "account": "alice", "asset": "USD/2", "amount": 9999 }
  ]
}
```

This format is available from numscript\@0.0.25. If you're on an older version, use the [legacy inputs schema](https://raw.githubusercontent.com/formancehq/numscript/refs/heads/main/inputs.schema.json) instead — it uses a map instead of an array for `balances` (and `metadata`).

You can run the file using:

```shellscript
numscript run my-script.num
```

You'll see the postings:

```
Postings:
| Source | Destination | Asset | Amount |
| alice  | world       | USD/2 | 100    |
```

## Test

Available from numscript\@0.0.19

You can use the `numscript test` command to check that the specs given in a [numscript specs format](https://docs.formance.com/v4.0/modules/numscript/specs) file are valid for a given numscript.

For example:

```shellscript
numscript test src/domain/numscript
```

This looks through the `src/domain/numscript` folder for every `<file>.num` that has a matching `<file>.num.specs.json` specs file.
