{"id":33919231,"url":"https://github.com/userx007/urustshell","last_synced_at":"2026-03-11T03:03:57.216Z","repository":{"id":321363029,"uuid":"1046793457","full_name":"userx007/uRustShell","owner":"userx007","description":"Framework for building shell-based applications in Rust","archived":false,"fork":false,"pushed_at":"2025-12-06T19:06:04.000Z","size":1188,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-08T21:25:07.376Z","etag":null,"topics":["autocomplete","cli","command-line","command-line-tool","history","rust","shell"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/userx007.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-29T08:29:26.000Z","updated_at":"2025-12-06T19:06:07.000Z","dependencies_parsed_at":"2025-10-29T09:16:24.162Z","dependency_job_id":"b053c98b-85fe-46e7-956f-e4970f3771fe","html_url":"https://github.com/userx007/uRustShell","commit_stats":null,"previous_names":["userx007/urustshell"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/userx007/uRustShell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userx007%2FuRustShell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userx007%2FuRustShell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userx007%2FuRustShell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userx007%2FuRustShell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/userx007","download_url":"https://codeload.github.com/userx007/uRustShell/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userx007%2FuRustShell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30368635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"online","status_checked_at":"2026-03-11T02:00:07.027Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocomplete","cli","command-line","command-line-tool","history","rust","shell"],"created_at":"2025-12-12T08:44:48.855Z","updated_at":"2026-03-11T03:03:57.209Z","avatar_url":"https://github.com/userx007.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uRustShell\n\n### ushell2 : the shell public interface\n[![Crates.io](https://img.shields.io/crates/v/ushell2)](https://crates.io/crates/ushell2)\n[![License](https://img.shields.io/crates/l/ushell2)](https://opensource.org/licenses/MIT)\n\n### ushell_dispatcher : shell subcomponent \n[![Crates.io](https://img.shields.io/crates/v/ushell_dispatcher)](https://crates.io/crates/ushell_dispatcher)\n[![License](https://img.shields.io/crates/l/ushell_dispatcher)](https://opensource.org/licenses/MIT)\n\n### ushell_input : shell subcomponent \n[![Crates.io](https://img.shields.io/crates/v/ushell_input)](https://crates.io/crates/ushell_input)\n[![License](https://img.shields.io/crates/l/ushell_input)](https://opensource.org/licenses/MIT)\n\n\n## Description\nThis Rust crate provides a framework for building shell-based applications.\nOnce launched, the application presents an interactive prompt that allows users to execute custom-defined commands.\n\nThe key advantage of this crate is the **simplicity of adding new commands** with any parameter configuration.\n\nIn practice, defining a new command requires adding just **one line** to a configuration file.\nFor example, given the function:\n\n```rust\nfn send (port: \u0026str, baud: u32, data: \u0026[u8]) {\n    // implementation\n}\n```\n\nyou can register it with a single line:\n\n```\nsDh : send_uart\n```\nFrom that point on, the command automatically benefits from full validation — including parameter count, types, and value ranges — without requiring any additional code.\n\nIntegration into your own code is also straightforward:\n\n```rust\nuse shell_runner::Shell;\n\nfn main() {\n    Shell::new().run();\n}\n```\n\n## Main Features\n\n* **Autocomplete** for faster command entry\n* **Command history** with recall support\n* **Editing mode** with intuitive navigation:\n\n  * Move cursor left/right using arrow keys\n  * Insert text under the cursor\n  * `DEL` deletes the character under the cursor\n  * `Ctrl-D` deletes the entire line\n  * `Ctrl-U` deletes from the cursor to the beginning\n  * `Ctrl-K` deletes from the cursor to the end\n* **Automatic parameter validation** (checks number, type, and range)\n* **Simple command registration** — add new commands with a single line in a configuration file\n* **Lightweight implementation** — commands are regular functions without special wrappers\n* **`no_std` by default**, making it suitable for heapless or embedded environments\n\n  * Optional heap usage can be enabled for larger command histories\n* **Flexible parameter types**, including:\n\n  * Unsigned integers: `u8`, `u16`, `u32`, `u64`, `u128`, `usize`\n  * Signed integers: `i8`, `i16`, `i32`, `i64`, `i128`, `isize`\n  * Floating-point: `f32`, `f64`\n  * Other: `char`, `bool`, `string`\n  * Byte arrays as hex strings (e.g. `AABBCC` → `{0xAA, 0xBB, 0xCC}`)\n* **Flexible number formats**: decimal (`1234`), hexadecimal (`0x3264`), octal (`0o3344`), binary (`0b11110011`)\n* **Shortcut support** for quick command execution (e.g. `##`, `.!aa`, etc.)\n\n\n## Parameter description\nAs a fast hint, the unsigned values having a bigger absolute value are marked with upper case symbols..\n\n| Symbol | Type   | Remark                                              |\n|--------|--------|-----------------------------------------------------|\n| B      | u8     | byte  - unsigned                                    |\n| W      | u16    | word  - unsigned                                    |\n| D      | u32    | dword - unsigned                                    |\n| Q      | u64    | qword - unsigned                                    |\n| X      | u128   | xword - unsigned                                    |\n| Z      | usize  | size  - unsigned                                    |\n| F      | f64    | double                                              |\n| b      | i8     | byte  - signed                                      |\n| w      | i16    | word  - signed                                      |\n| d      | i32    | dword - signed                                      |\n| q      | i64    | qword - signed                                      |\n| x      | i128   | xword - signed                                      |\n| z      | isize  | size  - signed                                      |\n| f      | f32    | float                                               |\n| c      | char   | char                                                |\n| t      | bool   | 1,true,True,TRUE, 0,false,False,FALSE               |\n| s      | string | hello or \"hey you\"                                  |\n| h      | array  | in hexadecimal, hexlified form, e.g. 12A6FFE3677    |\n| v      | void   | no params ..                                        |\n\n## Building arguments rule\nThis is quite simple and the array below shows few example ..\n\n| Function implementation                            | Rule | Config entry   | Shell call                    |\n|----------------------------------------------------|------|----------------|-------------------------------|\n| fn init ( )                                   {..} | v    | v   : init     | init                          |\n| fn read (descr:i8, nbytes:u32)                {..} | bD   | bD  : read     | read 0 1024                   |\n| fn write (filename:\u0026str, nbytes:u64, val:u8)  {..} | sQB  | sQb : write    | write output.txt 32768 0xFF   |\n| fn led (onoff: bool)                          {..} | t    | t   : led      | led true                      |\n| fn astring (input:\u0026str)                       {..} | s    | s   : astring  | astring \"Hello World!\"        |\n| fn greeting (s1: \u0026str, s2:\u0026str)               {..} | ss   | ss  : greeting | greeting hello \"Mr. Robinson\" |\n| fn send (port:\u0026str, baud:u32, data:\u0026[u8])     {..} | sDh  | sDh : send     | send COM2 115200 56EFA23C     |\n\n\n\n## Example Command Configuration: `uRustShell\\src\\usercode\\src\\commands.cfg`\n\n    v     : crate::uc::init,\n    bD    : crate::uc::read,\n    sQB   : crate::uc::write,\n    t     : crate::uc::led,\n    s     : crate::uc::astring\n            crate::uc::bstring\n            crate::uc::cstring,\n    ss    : crate::uc::greeting,\n    sDh   : crate::uc::send_uart,\n\n**Note:** As shown above, multiple commands can share a common rule (e.g., the commands `astring`, `bstring`, and `cstring`).\n\n## Running examples\n\n#### Listing registered commands and other information with `###`\n\n    \u003e ###\n\n    ⚡ Commands:\n     astring : s\n     bstring : s\n     cstring : s\n    greeting : ss\n        init : v\n         led : t\n        read : bD\n        send : sDh\n       write : sQB\n\n    ⚡ Shortcuts:\n    ### : list all\n    ##  : list cmds\n    #q  : exit\n    #h  : list history\n    #c  : clear history\n    #N  : exec from history at index N\n\n    ⚡ User shortcuts:\n    ++ | +l | +m | +? | +~ | .. | .z | .k | -. | -t | -u | -w\n\n    📝 Arg types:\n    B:u8   | W:u16  | D:u32 | Q:u64 | X:u128 | Z:usize | F:f64\n    b:i8   | w:i16  | d:i32 | q:i64 | x:i128 | z:isize | f:f32\n    v:void | c:char | s:str | t:bool | h:hexstr\n\n\n#### Running commangs with expected arguments\n\n    \u003e\n    \u003e\n    \u003e\n    \u003e led 0\n    led | OFF\n    ✅ Success: led 0\n    \u003e\n    \u003e led 1\n    led | ON\n    ✅ Success: led 1\n    \u003e\n    \u003e init\n    init | no-args\n    ✅ Success: init\n    \u003e greeting hello \"people around\"\n    greeting | [hello] : [people around]\n    ✅ Success: greeting hello \"people around\"\n    \u003e\n    \u003e read 0 1024\n    read | descriptor: 0, bytes:1024\n    ✅ Success: read 0 1024\n    \u003e send COM3 9600 11223344eeffaa56\n    send | port: COM3 baudrate: 9600, data:[17, 34, 51, 68, 238, 255, 170, 86]\n    ✅ Success: send COM3 9600 11223344eeffaa56\n    \u003e\n\n#### Running commands with wrong parameters\n\n    \u003e\n    \u003e led 2\n    ❌ Error: BadBool for line 'led 2'\n    \u003e\n    \u003e astring hello world\n    ❌ Error: WrongArity { expected: 1 } for line 'astring hello world'\n    \u003e init port\n    ❌ Error: WrongArity { expected: 0 } for line 'init port'\n    \u003e astring\n    ❌ Error: WrongArity { expected: 1 } for line 'astring '\n    \u003e read 256 1024\n    ❌ Error: BadSigned for line 'read 256 1024'\n    \u003e hello\n    ❌ Error: UnknownFunction for line 'hello'\n    \u003e\n\n#### Listing history\n\n    \u003e #h\n      0 : led 0\n      1 : led 1\n      2 : init\n      3 : greeting hello \"people around\"\n      4 : read 0 1024\n      5 : send COM3 9600 11223344eeffaa56\n      6 : led 5\n      7 : read -5 2048\n      8 : led 2\n      9 : astring hello world\n     10 : init port\n     11 : astring\n     12 : read 256 1024\n    📈 Left entries/bytes: 3/95\n    \u003e\n\n#### Running commangs from history (with the index from the list)\n\n    \u003e\n    \u003e #7\n    read | descriptor: -5, bytes:2048\n    ✅ Success: read -5 2048\n    \u003e #3\n    greeting | [hello] : [people around]\n    ✅ Success: greeting hello \"people around\"\n    \u003e #1\n    led | ON\n    ✅ Success: led 1\n    \u003e #0\n    led | OFF\n    ✅ Success: led 0\n    \u003e\n\n#### Cleaning history\n\n    \u003e #c\n    🧹 History cleared\n    \u003e #h\n    ⚠️ History is empty\n    \u003e #0\n    ⚠️ No history entry at index 0\n    \u003e\n\n## Shortcuts\n\n### Shell shortcuts (internal handling)\n\n    ### : list all, the commands and info\n    ##  : list commands only\n    #h  : list history\n    #c  : clear history\n    #N  : exec from history at index N\n    #q  : exit\n\n### User shortcuts\n\nBeside the commands, the shell supports also shortcuts (groups of symbols) with associated functions\n\n#### Shortcuts Configuration: `uRustShell\\src\\usercode\\src\\shortcuts.cfg`\n\nShortcuts are organized into **major/minor groups**, such as `++`, `+l`, or `+m` (see examples below).\n\n* For instance, typing `++` will execute the function `shortcut_plus_plus`.\n* If extra data is appended after the shortcut (e.g. `++data`), that data is passed as an argument to the function.\n* It is the function’s responsibility to handle this input — for example, to reject the call if no arguments are expected or to parse and process the provided data.\n\n\n#### Configuration example:\n\n    + : { + : crate::us::shortcut_plus_plus,\n          l : crate::us::shortcut_plus_l,\n          m : crate::us::shortcut_plus_m,\n          ? : crate::us::shortcut_plus_question_mark,\n          ~ : crate::us::shortcut_plus_tilde\n        },\n\n    . : { . : crate::us::shortcut_dot_dot,\n          z : crate::us::shortcut_dot_z,\n          k : crate::us::shortcut_dot_k\n        },\n\n    - : { . : crate::us::shortcut_minus_dot,\n          t : crate::us::shortcut_minus_t,\n          u : crate::us::shortcut_minus_u,\n          w : crate::us::shortcut_minus_w\n        },\n\nThe list of available shortcuts can be displayed using the `###` command.\n\n    ⚡ Shortcuts:\n    ++ | +l | +m | +? | +~ | .. | .z | .k | -. | -t | -u | -w\n\nThe shortcut implementations are defined in `uRustShell\\src\\usercode\\src\\shortcuts.rs`.\n\n#### ### Examples of Calling Shortcuts\n\n    \u003e ++\n    Executing ++ with param: ''\n    ✅ Success: ++\n    \u003e ++hello\n    Executing ++ with param: 'hello'\n    ✅ Success: ++hello\n    \u003e ++ aa bb cc\n    Executing ++ with param: 'aa bb cc'\n    ✅ Success: ++ aa bb cc\n    \u003e .z\n    Executing .z with param: ''\n    ✅ Success: .z\n    \u003e .z88\n    Executing .z with param: '88'\n    ✅ Success: .z88\n    \u003e\n\n## Local configuration\n\nThis file, `uRustShell\\src\\shell_config\\src\\lib.rs`, contains the shell configuration.\n\n    pub const PROMPT: \u0026str                  = \"\u003e \";\n    pub const INPUT_MAX_LEN :usize          = 128;\n    pub const HISTORY_TOTAL_CAPACITY :usize = 256;\n    pub const HISTORY_MAX_ENTRIES :usize    = 16;\n    pub const MAX_HEXSTR_LEN :usize         = 64;\n\nTo prevent users from entering more data than configured, keyboard input is automatically blocked once the limit is reached.\nIf you require additional input capacity, you can increase it in the configuration shown above.\n\n## Building and executing\n\n* Clone the repository locally.\n* Assuming that the Rust build environment is already installed, simply run `cargo run -p demo_app`.\n* This command will build and execute the test application using the provided test commands.\n* Replace these test commands with your own to obtain a fully functional, shell-based application tailored to your needs.\n* In principle, you should only need to modify the code in the `usercode` folder.\n\n## Template for Quick Start\n\nAn alternative approach is to extract the `urShell.zip` file from the `template` folder in the repository to your local machine and build it using `cargo run`. This template uses pre-published components from `crates.io`, making it the fastest way to integrate the shell into your project.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuserx007%2Furustshell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuserx007%2Furustshell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuserx007%2Furustshell/lists"}