|
| 1 | +# CLI |
| 2 | + |
| 3 | +The BlueScript CLI (`bscript`) is the primary tool for managing projects, setting up board environments, and running code on your devices. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install -g @bscript/cli |
| 9 | +``` |
| 10 | + |
| 11 | +## Project Management |
| 12 | + |
| 13 | +### `bscript project create` |
| 14 | + |
| 15 | +Creates a new BlueScript project with the necessary configuration files. |
| 16 | + |
| 17 | +```bash |
| 18 | +bscript project create <project-name> [options] |
| 19 | +``` |
| 20 | + |
| 21 | +This command generates a new directory containing: |
| 22 | +* `index.bs`: The main entry point for your application. |
| 23 | +* `bsconfig.json`: The project configuration file. |
| 24 | + |
| 25 | +**Arguments:** |
| 26 | +* `<project-name>`: The name of the directory to create. |
| 27 | + |
| 28 | +**Options:** |
| 29 | + |
| 30 | +| Option | Alias | Description | |
| 31 | +| :--- | :--- | :--- | |
| 32 | +| `--board` | `-b` | Specify the target board (e.g., `esp32`). If omitted, an interactive selection list will appear. | |
| 33 | + |
| 34 | +**Example:** |
| 35 | +```bash |
| 36 | +# Create a project interactively |
| 37 | +bscript project create my-app |
| 38 | + |
| 39 | +# Create a project specifically for ESP32 |
| 40 | +bscript project create my-app --board esp32 |
| 41 | +``` |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +### `bscript project install` |
| 46 | + |
| 47 | +Installs project dependencies. This command has two modes: |
| 48 | + |
| 49 | +1. **Install All:** If run without arguments, it installs all dependencies listed in bsconfig.json. |
| 50 | +2. **Add Package:** If a Git URL is provided, it downloads the package, adds it to bsconfig.json, and installs it. |
| 51 | + |
| 52 | +```bash |
| 53 | +bscript project install [git-url] [options] |
| 54 | +``` |
| 55 | + |
| 56 | +**Arguments:** |
| 57 | +* `<git-url>`: (Optional) The URL of the Git repository to add as a dependency. |
| 58 | + |
| 59 | +**Options:** |
| 60 | + |
| 61 | +| Option | Alias | Description | |
| 62 | +| :--- | :--- | :--- | |
| 63 | +| `--tag` | `-t` | Specify a git tag or branch to checkout (e.g., `v1.0.0`, `main`). | |
| 64 | + |
| 65 | +**Example:** |
| 66 | +```bash |
| 67 | +# Restore all dependencies from bsconfig.json |
| 68 | +bscript project install |
| 69 | + |
| 70 | +# Install a specific library (e.g., GPIO library) |
| 71 | +bscript project install https://github.com/bluescript/gpio.git |
| 72 | + |
| 73 | +# Install a specific version of a library |
| 74 | +bscript project install https://github.com/bluescript/drivers.git --tag v2.0.0 |
| 75 | +``` |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +### `bscript project uninstall` |
| 80 | + |
| 81 | +Uninstall the specified package from the current project. |
| 82 | + |
| 83 | +```bash |
| 84 | +bscript project uninstall [package-name] |
| 85 | +``` |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +### `bscript project run` |
| 90 | + |
| 91 | +Compiles the current project and executes it on a target device via Bluetooth. |
| 92 | + |
| 93 | +```bash |
| 94 | +bscript project run |
| 95 | +``` |
| 96 | + |
| 97 | +When you run this command: |
| 98 | +1. The CLI scans for available BlueScript devices over Bluetooth. |
| 99 | +2. The project is compiled into native code on your host machine. |
| 100 | +3. The code is transferred and executed immediately. |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | + |
| 105 | +## Board Management |
| 106 | + |
| 107 | +These commands manage the toolchains and runtime environments for specific hardware platforms. |
| 108 | + |
| 109 | +### `bscript board setup` |
| 110 | + |
| 111 | +Downloads and installs the necessary environment files and dependencies for a specific board architecture. |
| 112 | + |
| 113 | +```bash |
| 114 | +bscript board setup <board-name> |
| 115 | +``` |
| 116 | + |
| 117 | +**Arguments:** |
| 118 | +* `<board-name>`: The target board identifier (e.g., `esp32`). |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +### `bscript board flash-runtime` |
| 123 | + |
| 124 | +Flashes the BlueScript Runtime firmware onto the microcontroller. |
| 125 | +**Note:** This command requires a physical USB connection to the device. |
| 126 | + |
| 127 | +```bash |
| 128 | +bscript board flash-runtime <board-name> [options] |
| 129 | +``` |
| 130 | + |
| 131 | +**Arguments:** |
| 132 | +* `<board-name>`: The target board identifier. |
| 133 | + |
| 134 | +**Options:** |
| 135 | + |
| 136 | +| Option | Alias | Description | |
| 137 | +| :--- | :--- | :--- | |
| 138 | +| `--port` | `-p` | Specify the serial port connected to the device (e.g., `COM3`, `/dev/ttyUSB0`). If omitted, the CLI will list available ports for selection. | |
| 139 | + |
| 140 | +**Example:** |
| 141 | +```bash |
| 142 | +bscript board flash-runtime esp32 --port /dev/ttyUSB0 |
| 143 | +``` |
| 144 | + |
| 145 | +--- |
| 146 | + |
| 147 | +### `bscript board list` |
| 148 | + |
| 149 | +Lists all board architectures currently supported by the installed CLI version. |
| 150 | + |
| 151 | +```bash |
| 152 | +bscript board list |
| 153 | +``` |
| 154 | + |
| 155 | +--- |
| 156 | + |
| 157 | +### `bscript board remove` |
| 158 | + |
| 159 | +Removes the environment files and setup data for a specific board. |
| 160 | + |
| 161 | +```bash |
| 162 | +bscript board remove <board-name> [options] |
| 163 | +``` |
| 164 | + |
| 165 | +By default, this command asks for confirmation before deleting files. |
| 166 | + |
| 167 | +**Options:** |
| 168 | + |
| 169 | +| Option | Alias | Description | |
| 170 | +| :--- | :--- | :--- | |
| 171 | +| `--force` | `-f` | Skips the confirmation prompt and forces removal. | |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +### `bscript board fullclean` |
| 176 | + |
| 177 | +Completely removes all configuration and environment files for **all** boards. This returns the CLI board configurations to a fresh state. |
| 178 | + |
| 179 | +```bash |
| 180 | +bscript board fullclean |
| 181 | +``` |
| 182 | +By default, this command asks for confirmation before deleting files. |
| 183 | + |
| 184 | +**Options:** |
| 185 | + |
| 186 | +| Option | Alias | Description | |
| 187 | +| :--- | :--- | :--- | |
| 188 | +| `--force` | `-f` | Skips the confirmation prompt and forces removal. | |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## Other Commands |
| 193 | + |
| 194 | +### `bscript repl` |
| 195 | + |
| 196 | +Starts an interactive Read-Eval-Print Loop (REPL) session with the target device. |
| 197 | + |
| 198 | +```bash |
| 199 | +bscript repl --board <board-name> |
| 200 | +``` |
| 201 | + |
| 202 | +Unlike `bscript run` which compiles and sends the entire project, `bscript repl` utilizes the incremental compiler and shadow machine. It allows you to write code line-by-line, compiling only the differences and sending them to the device instantly via Bluetooth. |
| 203 | + |
| 204 | + |
| 205 | +**Options:** |
| 206 | + |
| 207 | +| Option | Alias | Description | |
| 208 | +| :--- | :--- | :--- | |
| 209 | +| `--board` | `-b` | Specify the target board (e.g., `esp32`). | |
0 commit comments