% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/print_rtree.R
\name{print_rtree}
\alias{print_rtree}
\title{Print an R Project or Directory Tree}
\usage{
print_rtree(
  path = NULL,
  ignore = c("renv", ".git", ".Rproj.user", "__pycache__", ".DS_Store", "node_modules",
    ".Rhistory"),
  ignore_type = c("auto", "fixed", "glob", "regex"),
  max_depth = NULL,
  show_hidden = FALSE,
  project = c("auto", "root", "none"),
  search_paths = c(".", "..", "~/Documents", "~/Projects"),
  root_markers = c(".Rproj", "DESCRIPTION"),
  format = c("ascii", "unicode"),
  return_lines = FALSE,
  quiet = FALSE,
  count_footer = TRUE,
  git = FALSE,
  git_legend = TRUE,
  prune = FALSE,
  snapshot = FALSE,
  snapshot_file = "tree.png",
  snapshot_width = 800,
  snapshot_bg = c("white", "black"),
  snapshot_path = "."
)
}
\arguments{
\item{path}{Character. Directory path, project name, or \code{.Rproj} file. If NULL, uses current directory.}

\item{ignore}{Character vector. Basenames to exclude (e.g., ".git", "renv").
With \code{ignore_type = "auto"}, entries containing wildcard characters are
treated as glob patterns, so values such as \code{"*.log"} or \code{"test_*"} work.}

\item{ignore_type}{One of "auto", "fixed", "glob", or "regex". Controls how
\code{ignore} is matched against basenames.}

\item{max_depth}{Integer. Maximum depth to traverse. NULL for unlimited.}

\item{show_hidden}{Logical (TRUE/FALSE). Whether to include hidden files/directories (starting with ".").}

\item{project}{One of "auto", "root", "none".
\itemize{
\item "auto": use \code{path} as-is (no upward search)
\item "root": walk upward from \code{path} to find a project root (via \code{root_markers}) and use it if found
\item "none": never attempt root detection; print the tree from \code{path}
}}

\item{search_paths}{Character vector. Used only when \code{path} is not an existing directory
(treated as a project name). Paths are searched in order.}

\item{root_markers}{Character vector. Markers used when \code{project = "root"} to detect a root directory.
Special value ".Rproj" means "any file ending in .Rproj". Common markers include "DESCRIPTION"
(R package root) and "_quarto.yml" (Quarto project root).}

\item{format}{One of "ascii" or "unicode". "ascii" is portable for all terminals.}

\item{return_lines}{Logical. If TRUE, invisibly return the printed character vector of lines.}

\item{quiet}{Logical. If TRUE, suppress console output. Useful with \code{return_lines = TRUE}.}

\item{count_footer}{Logical. If TRUE, append a summary like "3 directories, 12 files".}

\item{git}{Logical. If TRUE, annotate files and directories with porcelain
\verb{git status} markers when \code{path} is inside a Git work tree.}

\item{git_legend}{Logical. If TRUE and \code{git = TRUE}, append a short legend
explaining the Git status markers.}

\item{prune}{Logical. If TRUE, omit directories with no displayable children.}

\item{snapshot}{Logical. If TRUE, gives a visual snapshot of tree.}

\item{snapshot_file}{Text. Snapshot PNG name if snapshot is set as TRUE.}

\item{snapshot_width}{Integer. Default set at 800.}

\item{snapshot_bg}{Either white or black for snapshot background. If white, tree text appears black and vice.}

\item{snapshot_path}{Character. If snapshot_path is provided, the file is saved there.}
}
\value{
Invisible NULL, or a character vector of printed lines if \code{return_lines = TRUE}.
}
\description{
Prints a directory tree for a given path. Optionally, detects an RStudio project
(\code{.Rproj}) and can print from a project root.
}
\examples{
# Create a small example directory tree
demo <- file.path(tempdir(), "printtree-demo")
if (dir.exists(demo)) unlink(demo, recursive = TRUE)
dir.create(demo, recursive = TRUE)
dir.create(file.path(demo, "R"))
file.create(file.path(demo, "R", "hello.R"))
file.create(file.path(demo, "README.md"))

# Print the tree
print_rtree(demo)

# Limit depth
print_rtree(demo, max_depth = 1)

# Save a PNG snapshot to a temporary file
png_file <- tempfile(fileext = ".png")
print_rtree(demo, snapshot = TRUE, snapshot_file = png_file)
}
