-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Forward slashes break the display #5
Comments
So here is the problem: Line 42 in 5febe16
If this aims to print structured data, well this is a bug. If not is by design. |
Hi Pablo, Thanks for using When I wrote this gem my focus was on processing and displaying info for directories. That's what I needed it for. In this context, files and dir names with forward slashes are invalid, or put other way, they indicate new directory level. So in this sense, this is not a bug. Now, your expectation for printing a structured data is justifiable given my description. We could certainly assume that anytime hash gets provided we can take the data and render as is without any processing(e.i. skip walking down the directory structure). This would involve modifying the tree walking behaviour to only apply basename extraction for actual paths. Would you have time to work on this and submit PR with tests? One way to consider solving this would be to introduce a new node type and use it in hash traversal. |
Hi, sorry I took a quick look but seemed like it will take a solid couple of hours to do all that and I'm a bit low on time. Just wanted to leave a link to https://github.com/physacco/ruby-cli-tree/ that is what I've finally ended up using if anyone gets across the same issue. Is just a much simpler tree printer. |
we monkey patched the directory_renderer.rb to use require 'tty-tree'
module TTY
class Tree
class DirectoryRenderer
private
def render_node(acc, node, pipe_mark, space_mark)
acc << node.prefix.gsub(/:pipe/, pipe_mark).gsub(/:space/, space_mark)
unless node.root?
acc << MARKERS[:unicode][node.leaf? ? :leaf : :branch]
acc << ' '
end
# acc << node.name.to_s + "\n"
acc << node.path.to_s + "\n"
end
end # DirRenderer
end # Tree
end # TTY maybe the repo author would consider an option to print the path rather than name when calling the tree's render function |
Describe the problem
Everything before the last forward slash is lost.
Steps to reproduce the problem
Describe your environment
The text was updated successfully, but these errors were encountered: