Tutorial for adding file management to my project

My project has reached the point that I need to add file management. For instance, when saving a file, I need to give the user a way to navigate the directory system to choose the directory in which to save their file. At the same time the user needs to be able to enter a unique file name. This is mostly new territory for me so I've been doing lots of searches, trying to find a good solution and so far have come up dry. It is important to me that the code I write/implement be as simple and straightforward as possible, but the few solutions I've found seem to be far more complicated and difficult to implement than they should be (at least from my perspective). Is there something out there that will help me get this part of Rust learned? It would be really nice if it were written in tutorial fashion.

Thanks for your input. :nerd_face:

Oh, and for right now, my project is strictly terminal-based. I did find one solution that utilizes a GUI, but I'm not ready to jump into the GUI world yet.

I honestly don't think this would be a good UI. For a TUI, I would simply ask the user to provide the destination folder's path.

1 Like

You could use cursive to implement a file browser (TUI) - not sure if there is a ready made component you can re-use...

You make a good point, at least for where I am at with the program so far. The alternative is to add a TUI crate like cursive as was suggested by @Jesper below. I'm thinking that may be the way to go eventually, but right now I need to get the project to the point that it is at least usable in text-only mode. Then I can add more functionality and improve the user interface.

Thanks for getting back to me @moy2010. :>)

1 Like

I spent some time checking out cursive. As near as I can tell no one has created a file explorer example/framework that I can use in my project. However, a while back someone else recommended ratatui to me so I took a closer look at it this morning and they have developed an explorer feature for that crate. Check it out here. For the moment I'm going to go with @moy2010 's suggestion (check out my reply above) and just ask for the user to input the path. I can improve the user-interface later using cursive or ratatui whenever I'm ready to put the time into learning a new crate.

Thanks for your reply. :>)

2 Likes

There's a file explorer widget crate for Ratatui - ratatui-explorer

1 Like

Thanks, @joshka, I'll be checking that out sometime soon.

If you want to jump into the GUI side maybe iced or dioxus can help you. Also dioxus has TUI compatibility, I don't know if iced has.