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

Prompt to navigate through the filesystem and select one or more entries #63

Open
slinkydeveloper opened this issue Aug 8, 2022 · 4 comments
Milestone

Comments

@slinkydeveloper
Copy link

Is your feature request related to a problem? Please describe.
In my CLI I need to let the user select files navigating throughout the filesystem. Something along the lines of JavaFX FileChooser, or https://www.npmjs.com/package/inquirer-file-selector-prompt.

Describe the solution you'd like
It would be nice to have something built-in like FileSelect which you can use to point to a start directory, perhaps provide a file extension filter, and then let the user navigate and pick up the file. Right now I can implement this myself in my project, but I wonder if there's a room for this feature directly in this library.

@mikaelmello
Copy link
Owner

I think this would be a very valuable addition but as you must have encountered during implementation there is a lot of complexity when dealing with the filesystem. Specially when it comes to targeting all platforms as we try to do.

This feature would come great as a stand-alone package that builds upon our public API. Just like the NPM package you mentioned. What we lack here is a proper API to make that possible.

I'm thinking of getting the prompts to implement a common trait.

@mikaelmello
Copy link
Owner

I have thought more about it and think this is a good common use-case where a good enough approach would be appreciated by the public target of inquire.

@mikaelmello mikaelmello moved this to Wanted in Road to v1 Aug 19, 2022
@mikaelmello mikaelmello changed the title Select files Prompt to navigate through the filesystem and select one or more entries Aug 19, 2022
@mikaelmello
Copy link
Owner

By entries I mean either files or directories (or anything else that might exist really).

I envision this like Select/Multiselect prompts, but with better UX like allowing the user to go to parent directory pressing backspace.

Also, Select/Multiselect right now are very rigid on the options, which isn't good for a file-picking tool. The UX of this example is something I personally like. Maybe there is a way to wrap this into something more tailored for dealing with file-systems.

@mikaelmello mikaelmello added this to the v1.0.0 milestone Aug 19, 2022
@Dixaba
Copy link

Dixaba commented Oct 18, 2022

+1-ing this feature.
I've tried using code from complex_autocompletion example, and it worked for me almost perfectly!

However, here are some things to consider when creating a standalone component, based on issues/suggestions I found when using that example:

  • option to choose either only files, or a single directory (useful to ask where to create output files or something), or any set of items. I think it may be done as 2 separate settings - what is allowed to select, and how many (this is probably should be done as a validator?);
  • set initial value to current working dir (if not explicitly provided);
  • use std::path::MAIN_SEPARATOR as actual separator instead of hardcoded / (with /, suggestions doesn't work on Windows).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants