Skip to main content

Crate simple_shell

Crate simple_shell 

Source
Expand description

A simple polling-based no_std shell for embedded systems.

Pass Shell::new functions for writing text and reading bytes, then register commands in Shell::commands or with Shell::with_commands. Use Shell::run for a blocking loop or Shell::run_async in an async context.

§Example

use simple_shell::{Shell, ShellCommand};

fn run_shell() {
    // Replace these with your console I/O functions.
    let (write, read) = (|text: &str| print!("{text}"), || None);

    let mut shell = Shell::new(write, read).with_commands([(
        "help",
        ShellCommand {
            help: "print this help message",
            func: |_, shell| {
                shell.print_help_screen();
                Ok(())
            },
            aliases: &["?", "h"],
        },
    )]);

    shell.run();
}

Structs§

Shell
An interactive command shell.
ShellCommand
A command registered with a Shell.