nomad icon indicating copy to clipboard operation
nomad copied to clipboard

Feature/Enhancement Request | Live-print the tree instead of building before displaying

Open JosephLai241 opened this issue 1 year ago • 0 comments

Provide Context for the New Feature or Enhancement You Would Like

nomad currently builds the entire tree before it is displayed in the terminal. While this is not an issue when running nomad within smaller directories, it becomes substantial when running it in very large directories like /, for example. After running nd, it appears the command is hanging but nomad is actually just building the tree in the background.

Like what the original tree command appears to do, live-printing the tree as nomad finds new files or directories would provide a better user experience.

Explain Why You Believe This Would Be a Good Feature

Everyone loves a program that runs fast. Who actually likes waiting, especially for something written in Rust?

The hanging effect after running nd in big directories in the terminal may also cause confusion for the end user (ie. "did nomad crash?").

Is Your Request Related To a Problem?

I did not open a separate bug report for this since this is technically not a bug, but rather a performance issue.

Describe Alternatives You Have Considered

I have considered writing my own implementation of a tree-building library; however, I believe ptree is already a great crate, so why reinvent the wheel?

Additional Context

This is currently just a limitation of the default method of tree building that the ptree crate offers, since I did not implement a custom TreeItem trait and just used the provided TreeBuilder struct and print_tree_with() function to create and display the tree with custom formatting settings.

I believe this feature may be fulfilled once I take a deeper dive into the inner workings of ptree. If it is not possible to do by just implementing my own TreeItem trait, perhaps I would have to modify the source code and maybe even open a pull request for ptree adding a live print option of some sort when I figure it out. If I do open a PR for ptree and it is not accepted, I will just have to fork my own version of the crate and include it in nomad's source code.

JosephLai241 avatar Aug 24 '22 16:08 JosephLai241