forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shell/democommands: Add example Rust module
- Loading branch information
Showing
7 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "riot-module-shell-democommands" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
authors = ["Christian Amsüss <[email protected]>"] | ||
license = "LGPL-2.1-only" | ||
|
||
# Shipped with RIOT-OS; this has no external API that would make | ||
# sense to consume in any context than from within RIOT | ||
publish = false | ||
|
||
[dependencies] | ||
riot-wrappers = "^0.7.17" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![no_std] | ||
|
||
use riot_wrappers::println; | ||
use core::fmt::Write; | ||
|
||
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."), | ||
}; | ||
} |