| Crates.io | ushell2 |
| lib.rs | ushell2 |
| version | 0.1.0 |
| created_at | 2025-12-05 20:45:17.648167+00 |
| updated_at | 2025-12-05 20:45:17.648167+00 |
| description | Lightweight no_std shell runtime for interactive CLI applications |
| homepage | https://github.com/userx007/uRustShell |
| repository | https://github.com/userx007/uRustShell |
| max_upload_size | |
| id | 1969158 |
| size | 11,538 |
A lightweight, no_std compatible shell runtime component for building interactive command-line interfaces in Rust.
This crate provides the core Shell struct that orchestrates command execution, input parsing, and terminal management for shell-based applications. It's part of the uRustShell framework.
heapless data structures for embedded/constrained environmentsDebugshell-input — leverages autocomplete, history, and advanced editing featuresuse shell::Shell;
// Define your command and shortcut handlers
fn is_shortcut(input: &str) -> bool {
input.starts_with('+') || input.starts_with('.')
}
fn command_dispatcher(input: &str) -> Result<(), MyErrorType> {
// Parse and execute commands
Ok(())
}
fn shortcut_dispatcher(input: &str) -> Result<(), heapless::String<128>> {
// Handle shortcuts
Ok(())
}
// Create and run the shell
let mut shell = Shell::<
10, // NC: Number of commands
32, // FNL: Function name length
128, // IML: Input max length
256, // HTC: History total capacity
16, // HME: History max entries
MyErrorType,
>::new(
get_commands,
get_datatypes,
get_shortcuts,
is_shortcut,
command_dispatcher,
shortcut_dispatcher,
"> ",
);
shell.run();
The Shell type requires several const generic parameters to configure its behavior:
NC — Maximum number of registered commandsFNL — Maximum length of function namesIML — Maximum input line lengthHTC — Total capacity for history storage (in bytes)HME — Maximum number of history entriesERRTYPE — Error type returned by the command dispatcher (must implement Debug)The Shell::new() constructor accepts the following function pointers:
get_commands — Returns a static slice of (name, signature) tuples for available commandsget_datatypes — Returns a help string describing supported parameter typesget_shortcuts — Returns a help string listing available shortcutsis_shortcut — Predicate to determine if input should be treated as a shortcutcommand_dispatcher — Executes regular commandsshortcut_dispatcher — Executes shortcut commandsprompt — The prompt string to displayThe shell runs in a continuous loop, parsing input and dispatching to the appropriate handler:
InputParseris_shortcut predicateshortcut_dispatcher or command_dispatcher is calledBoth command and shortcut dispatchers can return errors:
ERRTYPE are converted to strings for displayheapless::String<IML>)Error: <message> for line '<input>'This crate is designed to work within the uRustShell framework, which provides:
.cfg filesFor a complete working example, see the uRustShell repository.
heapless — Stack-allocated data structuresshell-input — Input parsing and terminal managementThis crate is no_std compatible and suitable for embedded systems, though it does require terminal access for raw mode control.
See the uRustShell repository for license information.