From 685ccf583223287a1b2f4456bcf75893340457fc Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Thu, 17 Aug 2023 15:15:51 +0200 Subject: [PATCH] Add a quick start to the book (#202) --- book/src/SUMMARY.md | 2 ++ book/src/quick/README.md | 39 +++++++++++++++++++++++++++++++++++++++ crates/xtask/src/main.rs | 4 ++-- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 book/src/quick/README.md diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index e2836bc9a..746df378e 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -6,6 +6,8 @@ - [Terminology](overview/terminology.md) - [Features](overview/features.md) +- [Quick start](quick/README.md) + - [Applet user guide](applet/README.md) - [Setup](applet/setup.md) - [Create a new applet](applet/create.md) diff --git a/book/src/quick/README.md b/book/src/quick/README.md new file mode 100644 index 000000000..ad54a6192 --- /dev/null +++ b/book/src/quick/README.md @@ -0,0 +1,39 @@ +# Quick start + +## Repository setup + +Clone the repository and run the setup script: + +```sh +git clone https://github.com/google/wasefire +cd wasefire +./scripts/setup.sh +``` + +The setup script is best effort. When possible, it will directly invoke +installation commands, possibly asking for sudo password. Otherwise, it will +return an error and print a message about the next manual step. Once the problem +is addressed, the script must be run again. The script will eventually return a +success code indicating that no manual step is required and everything seems in +order. + +## Run an applet + +If you don't have a Nordic board, you can run applets on your desktop: + +```sh +cargo xtask applet assemblyscript hello runner host +``` + +If you have an nRF52840 dev-kit, you can also run applets on the board: + +```sh +cargo xtask applet rust blink runner nordic +``` + +The general format is `cargo xtask applet LANGUAGE NAME runner BOARD`. Example +applets are listed in the `examples` directory by _language_ then _name_. +_Boards_ are listed under the `crates` directory and are prefixed by `runner-`. + +Feel free to stop and play around by directly editing the examples. Or continue +reading for a deeper tutorial on how to write applets in Rust. diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index f7cff5270..0ce38ab7f 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -22,7 +22,7 @@ use std::path::Path; use std::process::{Command, Output}; use std::str::FromStr; -use anyhow::{ensure, Context, Result}; +use anyhow::{bail, ensure, Context, Result}; use clap::Parser; use lazy_static::lazy_static; use probe_rs::config::TargetSelector; @@ -257,7 +257,7 @@ impl AppletOptions { match self.lang.as_str() { "rust" => self.execute_rust(main), "assemblyscript" => self.execute_assemblyscript(main), - _ => panic!("unsupported language"), + x => bail!("unsupported language {x}"), } }