{"id":13822373,"url":"https://github.com/nathom/youchoose","last_synced_at":"2025-03-16T09:33:35.384Z","repository":{"id":50074916,"uuid":"369723765","full_name":"nathom/youchoose","owner":"nathom","description":"A lightweight terminal menu for Rust","archived":false,"fork":false,"pushed_at":"2023-01-29T17:18:09.000Z","size":1456,"stargazers_count":147,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-27T07:31:05.386Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-22T05:29:09.000Z","updated_at":"2025-02-18T02:59:55.000Z","dependencies_parsed_at":"2023-02-16T00:15:34.359Z","dependency_job_id":null,"html_url":"https://github.com/nathom/youchoose","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathom%2Fyouchoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathom%2Fyouchoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathom%2Fyouchoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathom%2Fyouchoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathom","download_url":"https://codeload.github.com/nathom/youchoose/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243810553,"owners_count":20351547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-04T08:01:57.313Z","updated_at":"2025-03-16T09:33:34.988Z","avatar_url":"https://github.com/nathom.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# youchoose\n\n[![crates.io](https://img.shields.io/crates/v/youchoose)](https://crates.io/crates/youchoose) [![docs.rs](https://img.shields.io/docsrs/youchoose)](https://docs.rs/youchoose)\n\nA simple, easy to use command line menu for Rust.\n\n## Usage\n\nThere are two methods you need to be familiar with to get started: `Menu::new` which takes an `Iterator` as an argument, and `Menu::show` which initializes `ncurses` and displays the menu.\n\nHere is a minimal example that displays the range `0..100` in a menu:\n\n```rust\nuse youchoose;\n\nfn main() {\n    let mut menu = youchoose::Menu::new(0..100);\n    let choice = menu.show();\n    // `choice` is a Vec\u003cusize\u003e containing the chosen indices\n    println!(\"Index of the chosen item: {:?}\", choice);\n}\n```\n\n![basic config](https://raw.githubusercontent.com/nathom/youchoose/main/screenshots/basic.png)\n\nEither `↓↑` or `jk` can be used to scroll, and `return` is used to select. `ESC` or `q` can be used to quit.\n\n**Previews**\n\n\nThe `youchoose::Menu` has a preview feature, which executes a command and shows the results on a separate pane. \n\n\n```rust\nuse youchoose;\n\nfn main(){\n    let mut menu = youchoose::Menu::new(0..100).preview(multiples);\n    let choice = menu.show();\n    println!(\"Chose {:?}\", choice);\n\n}\n\nfn multiples(num: i32) -\u003e String {\n    let mut buffer = String::new();\n    for i in 0..20 {\n        buffer.push_str(\n            \u0026format!(\"{} times {} is equal to {}!\\n\", num, i, num * i)\n        );\n    }\n    buffer\n}\n```\n\n![preview](https://raw.githubusercontent.com/nathom/youchoose/main/screenshots/with_preview.png)\n\n**Customization**\n\nLet's take a look at an example that showcases the available methods for customization.\n\n```rust\nuse youchoose;\n\nfn main() {\n    let mut menu = youchoose::Menu::new(0..100)\n        .preview(multiples)              // Sets the preview function\n        .preview_pos(youchoose::ScreenSide::Bottom, 0.3)  // Sets the position of the preview pane and its width across 0.0 and 1.0\n        .preview_label(\" multiples \".to_string())    // Sets the text at the top of the preview pane\n        .multiselect()                   // Allows multiple items to be selected\n        .icon(\":(\")                      // Sets the default (not selected) icon for an item\n        .selected_icon(\":)\")             // The icon for selected items\n        .add_multiselect_key('s' as i32) // Bind the 's' key to multiselect\n        .add_up_key('u' as i32)          // Bind the 'u' key to up\n        .add_down_key('d' as i32)        // Bind the 'd' key to down\n        .add_select_key('.' as i32);     // Bind the '.' key to select\n\n    let choice = menu.show();\n}\n\nfn multiples(num: i32) -\u003e String {\n    // --- Snip ---\n    format!(\"very custom: {}\", num)\n}\n\n```\n\n![fully customized](https://raw.githubusercontent.com/nathom/youchoose/main/screenshots/customized.png)\n\n## Contributions\n\nAll contributions, big or small, are welcome! If you would like to implement a new feature or fix a bug,\nopen a pull request to the `dev` branch. Please document any public functions or nontrivial code that \nyou add.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathom%2Fyouchoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathom%2Fyouchoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathom%2Fyouchoose/lists"}