1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 01:32:44 +01:00
RIOT/sys/shell/democommands/src/lib.rs

25 lines
589 B
Rust
Raw Normal View History

#![no_std]
use core::fmt::Write;
2024-10-02 22:17:08 +02:00
use riot_wrappers::println;
2024-10-02 22:17:08 +02:00
riot_wrappers::static_command!(
static_hello_world,
"hello_world",
"Print a greeting",
hello_world
);
2024-10-02 22:17:08 +02:00
pub fn hello_world<'a>(_w: &mut impl Write, args: impl IntoIterator<Item = &'a str>) {
let mut args = args.into_iter();
2024-10-02 22:17:08 +02:00
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."),
};
}