Files
mist-website/content/docs/index.mdx
T

101 lines
2.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Get Started
description: This guide will walk you through installing the Mist CLI, setting up your development environment, and compiling your very first program.
icon: Rocket
---
## 1. Installation
Mist is currently distributed as a Cargo crate. To get started, you'll need to have the Rust toolchain installed.
Run the following command to install the Mist compiler:
```bash title="Terminal"
cargo install [email protected]
```
Once the installation finishes, verify it by checking the version:
```bash title="Terminal"
mist version
```
---
## 2. Setting Up Your Project
Mist works alongside Cargo to handle the heavy lifting. Follow these steps to prepare your environment for your first "Hello World" program.
### Initialize a New Project
If you haven't already, create a new Cargo project and navigate into the directory:
```bash title="Terminal"
cargo new my-mist-app
cd my-mist-app
```
### Configure Mist
Create a `mist.json` file in your root directory. This tells the compiler where to look for your source code and where to place the generated Rust files.
```json title="mist.json"
{
"src": "src",
"output": "build"
}
```
### Link Cargo to Mist
Since Mist compiles down to Rust, you need to point Cargo to the generated output. Update your `Cargo.toml` to include the following:
```toml title="Cargo.toml"
[[bin]]
name = "main"
path = "build/main.rs"
```
> **Pro Tip:** You’ll probably want to add `/build` to your `.gitignore` file to keep your repository clean!
---
## 3. Your First Program
Now for the fun part! Create a new file at `src/main.mist` and add the following code:
```mist title="src/main.mist"
void main() {
println!("Hello World!");
}
```
### Build and Run
To turn your Mist code into an executable, use the `run` command:
```bash title="Terminal"
mist run
```
> **Pro Tip:** If you encounter any rust errors, head to the build directory and analyze the output, if you see anything unusual in the output, report the issue at https://github.com/mist-go/mist
Or if you only want to transpile to rust
```bash title="Terminal"
mist transpile
```
---
## Command Reference
| Command | Description |
| ---------------- | ----------------------------------------------- |
| `mist run` | Runs the project in the current directory |
| `mist build` | builds the project in the current directory |
| `mist transpile` | transpiles the project in the current directory |
| `mist version` | prints the compiler version |
| `mist help` | prints this message |