mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
use crate::{ShellCmdApi,CommonEnv};
|
|
use xous_ipc::String;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Test {
|
|
state: u32
|
|
}
|
|
impl Test {
|
|
pub fn new() -> Self {
|
|
Test {
|
|
state: 0
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<'a> ShellCmdApi<'a> for Test {
|
|
cmd_api!(test);
|
|
|
|
fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
|
use core::fmt::Write;
|
|
|
|
self.state += 1;
|
|
let mut ret = String::<1024>::new();
|
|
write!(ret, "Test has run {} times.\n", self.state).unwrap();
|
|
|
|
let mut tokens = args.as_str().unwrap().split(' ');
|
|
|
|
if let Some(sub_cmd) = tokens.next() {
|
|
match sub_cmd {
|
|
"devboot" => {
|
|
env.gam.set_devboot(true).unwrap();
|
|
write!(ret, "devboot on").unwrap();
|
|
}
|
|
"devbootoff" => {
|
|
// this should do nothing if devboot was already set
|
|
env.gam.set_devboot(false).unwrap();
|
|
write!(ret, "devboot off").unwrap();
|
|
}
|
|
_ => {
|
|
() // do nothing
|
|
}
|
|
}
|
|
|
|
}
|
|
Ok(Some(ret))
|
|
|
|
}
|
|
}
|