riot_module_shell_democommands/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#![no_std]

use core::fmt::Write;
use riot_wrappers::println;

riot_wrappers::static_command!(
    static_hello_world,
    "hello_world",
    "Print a greeting",
    hello_world
);

pub fn hello_world<'a>(_w: &mut impl Write, args: impl IntoIterator<Item = &'a str>) {
    let mut args = args.into_iter();
    let commandname = args
        .next()
        .expect("How was this started without an argv[0]?");

    match args.next() {
        Some("--help") => println!("Usage: {commandname}"),
        None => println!("Hello RIOT!"),
        _ => println!("Invalid argument."),
    };
}