draw_path_tree: Draw path tree

draw_path_treeR Documentation

Draw path tree

Description

Pretty-prints a character vector of hierarchical paths as a tree. Uses Unicode box drawing characters to draw the nesting structure.

Usage

draw_path_tree(paths, quiet = FALSE)

Arguments

paths

A character vector of paths as returned by flatten_path_tree() or fs::dir_ls().

quiet

Whether or not to suppress drawing the directory tree.

Details

This function is the equivalent of fs::dir_tree() for an artificial/fictional path hierarchy. To print a tree of an actual filesystem path hierarchy, it's recommended to rely on fs::dir_tree() which additionally colorizes the output based on real filesystem information. Apart from that, the algorithm to draw the tree is the same.

Value

paths, invisibly.

See Also

Other path functions: flatten_path_tree(), path_mod_time()

Examples

# using an artificial/fictional path hierarchy
list("root_dir" = list("subdir1",
                       "subdir2" = list("file1.ext"),
                       "file2.ext")) |>
  pal::flatten_path_tree() |>
  pal::draw_path_tree()

# using an actual path hierarchy
fs::path_package("dplyr") |>
  fs::dir_ls(recurse = TRUE) |>
  pal::draw_path_tree()

# to get colorized output, use `fs::dir_tree()` instead
fs::path_package("dplyr") |> fs::dir_tree()

salim-b/pal documentation built on Feb. 28, 2025, 6:51 p.m.