Skip to content

Commit 63b47fb

Browse files
committed
shell.rs: Add alias handling WIP
1 parent bba4316 commit 63b47fb

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

examples/xbd-net/src/xbd/shell.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,22 @@ pub async fn process_shell_stream() -> Result<(), i8> {
7272
let mut stream = XbdStream::new_with_cap(&SD, 1);
7373
prompt();
7474

75-
while let Some(line_buf) = stream.next().await {
76-
println!("[async shell] (null terminated) line_buf: {} (len: {} SHELL_BUFSIZE: {})",
77-
line_buf, line_buf.len(), SHELL_BUFSIZE);
78-
//println!(" line_buf.as_bytes(): {:?}", line_buf.as_bytes());
79-
//println!(" line_buf: {:?}", line_buf);
75+
while let Some(mut line) = stream.next().await {
76+
println!("[async shell] (null terminated) line: {} (len: {} SHELL_BUFSIZE: {})",
77+
line, line.len(), SHELL_BUFSIZE);
78+
//println!(" line.as_bytes(): {:?}", line.as_bytes());
79+
//println!(" line: {:?}", line);
80+
81+
match line.as_str() { // alias handling
82+
"h\0" => {
83+
line.clear();
84+
line.push_str("help\0").unwrap();
85+
},
86+
// ...
87+
_ => (),
88+
}
8089

81-
unsafe { handle_input_line_minerva(shell_commands, line_buf.as_ptr()); }
90+
unsafe { handle_input_line_minerva(shell_commands, line.as_ptr()); }
8291

8392
if 0 == 1 { crate::Xbd::async_sleep(1_000).await; } // debug, ok
8493

0 commit comments

Comments
 (0)