% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/decode-webr-repl-link.R
\name{decode_webr_link}
\alias{decode_webr_link}
\title{Decode webR REPL link(s) to extract files to local directory}
\usage{
decode_webr_link(
  url,
  output_dir = file.path(tempdir(), "webr_files"),
  overwrite = FALSE,
  create_subdir = TRUE,
  name_dirs = TRUE
)
}
\arguments{
\item{url}{Character string or vector containing webR REPL URL(s)}

\item{output_dir}{Character string specifying the output directory path.
Defaults to a \code{webr_files} directory inside the session temporary
directory; pass an explicit path to extract somewhere permanent.}

\item{overwrite}{Logical. Whether to overwrite existing files (default: FALSE)}

\item{create_subdir}{Logical. If \code{TRUE} (default), each decoded link is
extracted into its own subdirectory under \code{output_dir} rather than directly
into it. For a single URL the subdirectory is named \verb{webr_<hash>}, where
\verb{<hash>} is a short fingerprint of the URL. For multiple URLs, see
\code{name_dirs}. Set \code{FALSE} to extract straight into \code{output_dir}.}

\item{name_dirs}{Logical. For multiple URLs, controls how the per-link
subdirectories are named: \code{TRUE} (default) numbers them \code{script_01},
\code{script_02}, ...; \code{FALSE} names each one \verb{webr_<hash>} from the URL
fingerprint. Ignored for a single URL, and ignored when
\code{create_subdir = FALSE} (all files then extract into \code{output_dir}).}
}
\value{
For a single URL, a \code{webr_decoded} object. For multiple URLs, a
\code{webr_decoded_batch} object.
}
\description{
Decodes webR REPL sharelinks to extract the embedded files and save them
to a local directory. This is the reverse operation of creating webR links.
Handles both single URLs and multiple URLs automatically.
}
\examples{
# Round-trip: build a link, then decode it back to files
url <- as.character(webr_repl_link("plot(1:10)"))

result <- decode_webr_link(url)
print(result)

# Extract to a directory of your choosing
out <- file.path(tempdir(), "my_code")
decode_webr_link(url, output_dir = out, create_subdir = FALSE, overwrite = TRUE)
list.files(out)

# Several links at once
urls <- c(url, as.character(webr_repl_link("hist(rnorm(100))")))
decode_webr_link(urls, output_dir = file.path(tempdir(), "my_scripts"))
}
\seealso{
\code{\link[=preview_webr_link]{preview_webr_link()}} to inspect a link without writing files, and
\code{\link[=webr_repl_link]{webr_repl_link()}}, \code{\link[=webr_repl_project]{webr_repl_project()}}, and \code{\link[=webr_repl_exercise]{webr_repl_exercise()}}, which
create the links this function decodes.
}
