12345678910111213141516171819202122232425262728293031323334353637383940 |
- use easy_repl::{command, CommandStatus, Repl};
- use crate::syscall;
- pub fn mgr_shell() {
- let repl_bresult = Repl::builder()
- .description("admin shell")
- .prompt("[ M-Admin-Sh ] ")
- .add("hello", command! {
- "print hello",
- () => || {
- println!("hello!");
- Ok(CommandStatus::Done)
- }
- })
- .add("exec", command! {
- "run a command, without arguments",
- (shell: String) => |shell:String| {
- syscall::proc::shell_exec_cmd(shell);
- Ok(CommandStatus::Done)
- }
- })
- .build();
- let mut repl = match repl_bresult {
- Ok(t) => t,
- Err(err) => {
- println!("[ERROR] admin Shell Init Fatal Error: {:?}", err);
- return;
- }
- };
- let repl_run_result = repl.run();
- match repl_run_result {
- Ok(_) => {
- println!("Back to maintenance shell.");
- }
- Err(err) => {
- println!("[ERROR] admin shell crash by error: {:?}", err);
- println!("Back to maintenance shell.");
- }
- };
- }
|