Skip to content

Commit

Permalink
minimal viable folder selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Gadorek committed Jul 4, 2024
1 parent 6244c77 commit d053cb9
Show file tree
Hide file tree
Showing 8 changed files with 459 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fuzzy-select = ["fuzzy-matcher"]
history = []
password = ["zeroize"]
completion = []
folder-select = []

[dependencies]
console = "0.15.0"
Expand Down Expand Up @@ -52,6 +53,10 @@ required-features = ["history"]
name = "completion"
required-features = ["completion"]

[[example]]
name = "folder_select"
required-features = ["folder-select"]

[workspace.metadata.workspaces]
no_individual_tags = true

Expand Down
20 changes: 20 additions & 0 deletions examples/folder_select.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use dialoguer::{theme::ColorfulTheme, FolderSelect};

fn main() {
let selection = FolderSelect::with_theme(&ColorfulTheme::default())
.with_prompt("Select some sobfolder from /tmp")
.folder("/tmp")
.interact()
.unwrap();

println!("Folder you selected: {}", selection);

let selection = FolderSelect::with_theme(&ColorfulTheme::default())
.with_prompt("Select some file from /tmp")
.folder("/tmp")
.file(true)
.interact()
.unwrap();

println!("File you selected: {}", selection);
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub use prompts::{
confirm::Confirm, input::Input, multi_select::MultiSelect, select::Select, sort::Sort,
};

#[cfg(feature = "fuzzy-select")]
pub use prompts::folder_select::FolderSelect;

#[cfg(feature = "completion")]
mod completion;
#[cfg(feature = "editor")]
Expand Down
Loading

0 comments on commit d053cb9

Please sign in to comment.