/rust-cli-workshop

Workshop to learn and practice Rust by building CLI (ongoing)

Primary LanguageRustMIT LicenseMIT

Rust

screenshot

Learn Rust by building Command Line Application

Repository used for workshop

🎯 What we will build

🦀 Crabby command line !

$ crabby --help

Crabby cli

Usage: crabby_api <COMMAND>

Commands:
  greets    Greets with name
  chifoumi  Play chifoumi with players
  search    Search news by keyword
  help      Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

📝 Requirements

You'll need to install:

TLDR;

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

⚠️ Note on Windows

Rust requires certain C++ build tools. You can either download the Microsoft C++ Build Tools, or (recommended) you might prefer just to install Microsoft Visual Studio.

More about Installation setup on windows

Verify your toolchain version

Minimum Version : 1.72+ (tested)

rustc --version
rustc 1.72.1 (d5c2e9c34 2023-09-13)

Keep your rust up-to-date with the latest release of rust, type:

rustup update

Choose your IDE

More tools on Rust website

Alternative to IDE

When your computer is annoying or you are not admin...

📝 Workshop instructions

👀 Solutions

❗ Try your solution first. Errors help to learn with Rust

Each part have a working solution

// inside each directory
cd <partx>/solutions
cargo run

Run solutions :

// from git root directory
cargo run --bin crabby_setup
cargo run --bin crabby_syntax
cargo run --bin crabby_args
cargo run --bin crabby_cli
cargo run --bin crabby_api

bin name is defined in related <partx>/solutions/Cargo.toml files

⚡ Tests

You are not required to write test during workshop but it always a good pratice so have a look !

// all
cargo test

//specific
cargo test --bin crabby_setup
cargo test --bin crabby_syntax
cargo test --bin crabby_args
cargo test --bin crabby_mod
cargo test --bin crabby_cli
cargo test --bin crabby_api

📚 Additional resources