Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filepath select #138

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ba1b47f
Cargo feature for path select
anwarhahjjeffersongeorge May 8, 2023
b6b7501
Support path feature in vscode
anwarhahjjeffersongeorge May 8, 2023
2082f9d
Basic path select prompt and builder
anwarhahjjeffersongeorge May 8, 2023
f5e3af4
Path select prompt examples
anwarhahjjeffersongeorge May 8, 2023
652d1d4
show hidden files option
anwarhahjjeffersongeorge May 8, 2023
7acd6f0
bugfix respect multi-selection mode, refactor pathentry
anwarhahjjeffersongeorge May 9, 2023
07c509b
support optionally showing/browsing symlinks
anwarhahjjeffersongeorge May 9, 2023
2757f97
multiselection mode fix
anwarhahjjeffersongeorge May 9, 2023
5c4b526
rustfmt
anwarhahjjeffersongeorge May 9, 2023
5142567
warnings
anwarhahjjeffersongeorge May 9, 2023
32006bb
Merge branch 'main' into filepath-select
anwarhahjjeffersongeorge May 9, 2023
be8141c
Update path select to new architecture
anwarhahjjeffersongeorge May 9, 2023
5c91a31
rustfmt
anwarhahjjeffersongeorge May 9, 2023
52792a2
do not use nightly features, cleanup unused imports
anwarhahjjeffersongeorge May 9, 2023
9410369
don't derive default on enum to suport msrv
anwarhahjjeffersongeorge May 9, 2023
d382d0c
Update inquire/src/prompts/path_select/action.rs
anwarhahjjeffersongeorge May 17, 2023
f4f31e5
Update inquire/src/prompts/path_select/action.rs
anwarhahjjeffersongeorge May 17, 2023
c2458e3
Update inquire/src/prompts/path_select/mod.rs
anwarhahjjeffersongeorge May 17, 2023
923d2a7
Remove vim mode as suggested at https://github.com/mikaelmello/inquir…
anwarhahjjeffersongeorge May 17, 2023
4a01e87
Add note about vim mode support.
anwarhahjjeffersongeorge May 17, 2023
83e31af
Bust out PathEntry into its own module
anwarhahjjeffersongeorge May 18, 2023
87e31aa
spacing
anwarhahjjeffersongeorge May 18, 2023
8f58450
file size information and sorting modes
anwarhahjjeffersongeorge May 18, 2023
e67a0e5
- Move PathEntry to own module
anwarhahjjeffersongeorge May 18, 2023
ec22cab
remove vim mode option
anwarhahjjeffersongeorge May 18, 2023
7b6d157
Improve display by selectively stripping prefixes
anwarhahjjeffersongeorge May 18, 2023
94c01f8
Relocate `is_path_hidden_file` method to PathSelectPrompt
anwarhahjjeffersongeorge May 18, 2023
3b2df27
remove example
anwarhahjjeffersongeorge May 18, 2023
4b6d119
Update inquire/src/prompts/path_select/mod.rs
anwarhahjjeffersongeorge Aug 13, 2023
1099e74
Update inquire/src/prompts/path_select/mod.rs
anwarhahjjeffersongeorge Aug 13, 2023
3b80840
Update inquire/src/prompts/path_select/mod.rs
anwarhahjjeffersongeorge Aug 13, 2023
c29a281
Update inquire/src/prompts/path_select/prompt.rs
anwarhahjjeffersongeorge Aug 13, 2023
b87ca59
Update inquire/src/prompts/path_select/mod.rs
anwarhahjjeffersongeorge Aug 13, 2023
58d0586
Update inquire/src/prompts/path_select/mod.rs
anwarhahjjeffersongeorge Aug 13, 2023
ec8a71b
unneccessary brace
anwarhahjjeffersongeorge Aug 13, 2023
db958ad
- Eliminate raw_prompt,
anwarhahjjeffersongeorge Aug 14, 2023
a5f53ec
Support PathFilter,
anwarhahjjeffersongeorge Aug 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove example
anwarhahjjeffersongeorge committed May 18, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 3b2df2704bb0bc5f6bb390996b4cb583d708eee7
38 changes: 3 additions & 35 deletions inquire/src/prompts/path_select/prompt.rs
Original file line number Diff line number Diff line change
@@ -50,20 +50,6 @@ impl<'a> PathSelectPrompt<'a> {
pub fn new<T: AsRef<Path>>(pso: PathSelect<'a, T>) -> InquireResult<Self> {
let config = PathSelectConfig::from(&pso);

if let Some(default) = pso.default {
default.iter().try_for_each(|default_item| {
// Are all of the selected files extant?
let default_path = default_item.as_ref();
if !default_path.exists() {
Err(InquireError::InvalidConfiguration(format!(
"Specified default path `{default_path:?}` does not exist"
)))
} else {
Ok(())
}
})?;
}

let mut start_path = if let Some(start) = pso.start_path_opt {
start.as_ref().to_path_buf()
} else {
@@ -79,7 +65,9 @@ impl<'a> PathSelectPrompt<'a> {
let selected_options = pso.default.map_or_else(
|| Result::<_, InquireError>::Ok(HashSet::<PathEntry>::new()),
|d| {
d.iter().try_fold(HashSet::new(), |mut s, d| {
d.iter()
.filter(|default_path| default_path.as_ref().exists())
.try_fold(HashSet::new(), |mut s, d| {
s.insert(PathEntry::try_from(d.as_ref())?);
Ok(s)
})
@@ -251,26 +239,6 @@ impl<'a> PathSelectPrompt<'a> {
}

/// Test if a path is hidden file.
///
/// ### Problems
/// This is missing some things described here:
/// https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory
/// - android: .nomedia files that tell smartphone apps not to display/include a folder's contets
/// - gnome: filenames listed inside a file named ".hidden" in each directory should be hidden
/// - macos: files with Invisible attribute are usually hidden in Finder but not in `ls`
/// - windows: files with a Hidden file attribute
/// - windows: files in folders with a predefined CLSID on the end of their names (Windows Special Folders)
///
/// ```
/// use inquire::PathSelect;
/// use std::path::Path;
///
/// assert!(PathSelect::is_path_hidden_file(Path::new("/ra/set/.nut")));
/// assert!(!PathSelect::is_path_hidden_file(Path::new("/ra/set/nut")));
/// assert!(PathSelect::is_path_hidden_file(Path::new(".maat")));
/// assert!(!PathSelect::is_path_hidden_file(Path::new("maat")));
///
/// ```
fn is_path_hidden_file<T: AsRef<Path>>(t: T) -> bool {
if cfg!(unix) {
t.as_ref()