Skip to content

Commit

Permalink
feat: list (#51)
Browse files Browse the repository at this point in the history
* feat: input suggestions are now a slice

chore: update examples

* refactor: SpinnerActions doesnt need to be exported, that was from an earlier version of run actions

* fix: typo

* feat: allow non static str

* feat: SpinnerActionRunner.title now accepts into<string>

* fix: input not showing cursor when done

* fix: clippy warnings

* feat: fancy list
chore: test
chore: examples
  • Loading branch information
Vulpesx authored May 10, 2024
1 parent 37a49e4 commit d7e3246
Show file tree
Hide file tree
Showing 5 changed files with 409 additions and 2 deletions.
81 changes: 81 additions & 0 deletions examples/list.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
use demand::List;

fn main() {
let _ = List::new("hewo")
.description("so many things")
.items(&[
"hi",
"hewo",
"how are u",
"i like trains",
":3",
"do you like jazz",
"hehe",
])
.filterable(true)
.run();
let _ = List::new("long hewo")
.item("Lettuce")
.item("Tomatoes")
.item("Charm Sauce")
.item("Jalapenos")
.item("Cheese")
.item("Vegan Cheese")
.item("Nutella")
.item("Peanut Butter")
.item("Banana")
.item("Strawberries")
.item("Blueberries")
.item("Pineapple")
.item("Mango")
.item("Kiwi")
.item("Passion Fruit")
.item("Peaches")
.item("Raspberries")
.item("Blackberries")
.item("Mint")
.item("Chocolate Chips")
.item("Oreos")
.item("Brownie Bites")
.item("Cookie Dough")
.item("Graham Cracker Crumbs")
.item("M&Ms")
.item("Reese's Pieces")
.item("Butterfinger")
.item("Heath Bar")
.item("Kit Kat")
.item("Snickers")
.item("Twix")
.item("Caramel")
.item("Hot Fudge")
.item("Marshmallow")
.item("Whipped Cream")
.item("Chocolate Syrup")
.item("Caramel Syrup")
.item("Strawberry Syrup")
.item("Peanut Butter Syrup")
.item("Nutella Syrup")
.item("Honey")
.item("Sprinkles")
.item("Chocolate Sprinkles")
.item("Coconut Flakes")
.item("Almonds")
.item("Peanuts")
.item("Walnuts")
.item("Pecans")
.item("Cashews")
.item("Pistachios")
.item("Macadamia Nuts")
.item("Hazelnuts")
.item("Peanut Butter Cups")
.item("Gummy Bears")
.item("Sour Patch Kids")
.item("Sour Gummy Worms")
.item("Sour Skittles")
.item("Skittles")
.item("Starburst")
.item("Twizzlers")
.item("Milk Duds")
.filterable(true)
.run();
}
1 change: 1 addition & 0 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ impl<'a> Input<'a> {
self.clear_err()?;
self.validate()?;
if self.err.is_none() {
self.term.show_cursor()?;
return self.handle_submit();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pub use confirm::Confirm;
pub use input::Input;
pub use list::List;
pub use multiselect::MultiSelect;
pub use option::DemandOption;
pub use select::Select;
Expand All @@ -11,6 +12,7 @@ pub use theme::Theme;

mod confirm;
mod input;
mod list;
mod multiselect;
mod option;
mod select;
Expand Down
Loading

0 comments on commit d7e3246

Please sign in to comment.