EVOLUTION-MANAGER
Edit File: proj_utils.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Utility functions for the active project</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for proj_utils {usethis}"><tr><td>proj_utils {usethis}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Utility functions for the active project</h2> <h3>Description</h3> <p>Most <code style="white-space: pre;">use_*()</code> functions act on the <strong>active project</strong>. If it is unset, usethis uses <a href="https://rprojroot.r-lib.org">rprojroot</a> to find the project root of the current working directory. It establishes the project root by looking for a <code>.here</code> file, an RStudio Project, a package <code>DESCRIPTION</code>, Git infrastructure, a <code>remake.yml</code> file, or a <code>.projectile</code> file. It then stores the active project for use for the remainder of the session. </p> <h3>Usage</h3> <pre> proj_get() proj_set(path = ".", force = FALSE) proj_path(..., ext = "") with_project( path = ".", code, force = FALSE, setwd = TRUE, quiet = getOption("usethis.quiet", default = FALSE) ) local_project( path = ".", force = FALSE, setwd = TRUE, quiet = getOption("usethis.quiet", default = FALSE), .local_envir = parent.frame() ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>path</code></td> <td> <p>Path to set. This <code>path</code> should exist or be <code>NULL</code>.</p> </td></tr> <tr valign="top"><td><code>force</code></td> <td> <p>If <code>TRUE</code>, use this path without checking the usual criteria for a project. Use sparingly! The main application is to solve a temporary chicken-egg problem: you need to set the active project in order to add project-signalling infrastructure, such as initialising a Git repo or adding a <code>DESCRIPTION</code> file.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>character vectors, if any values are NA, the result will also be NA. The paths follow the recycling rules used in the tibble package, namely that only length 1 arguments are recycled.</p> </td></tr> <tr valign="top"><td><code>ext</code></td> <td> <p>An optional extension to append to the generated path.</p> </td></tr> <tr valign="top"><td><code>code</code></td> <td> <p>Code to run with temporary active project</p> </td></tr> <tr valign="top"><td><code>setwd</code></td> <td> <p>Whether to also temporarily set the working directory to the active project, if it is not <code>NULL</code></p> </td></tr> <tr valign="top"><td><code>quiet</code></td> <td> <p>Whether to suppress user-facing messages, while operating in the temporary active project</p> </td></tr> <tr valign="top"><td><code>.local_envir</code></td> <td> <p>The environment to use for scoping. Defaults to current execution environment.</p> </td></tr> </table> <h3>Details</h3> <p>In general, end user scripts should not contain direct calls to <code style="white-space: pre;">usethis::proj_*()</code> utility functions. They are internal functions that are exported for occasional interactive use or use in packages that extend usethis. End user code should call functions in <a href="https://rprojroot.r-lib.org">rprojroot</a> or its simpler companion, <a href="https://here.r-lib.org">here</a>, to programmatically detect a project and build paths within it. </p> <h3>Functions</h3> <ul> <li> <p><code>proj_get</code>: Retrieves the active project and, if necessary, attempts to set it in the first place. </p> </li> <li> <p><code>proj_set</code>: Sets the active project. </p> </li> <li> <p><code>proj_path</code>: Builds a path within the active project returned by <code>proj_get()</code>. Thin wrapper around <code><a href="../../fs/html/path.html">fs::path()</a></code>. </p> </li> <li> <p><code>with_project</code>: Runs code with a temporary active project and, optionally, working directory. It is an example of the <code style="white-space: pre;">with_*()</code> functions in <a href="https://withr.r-lib.org">withr</a>. </p> </li> <li> <p><code>local_project</code>: Sets an active project and, optionally, working directory until the current execution environment goes out of scope, e.g. the end of the current function or test. It is an example of the <code style="white-space: pre;">local_*()</code> functions in <a href="https://withr.r-lib.org">withr</a>. </p> </li></ul> <h3>See Also</h3> <p>Other project functions: <code><a href="proj_sitrep.html">proj_sitrep</a>()</code> </p> <h3>Examples</h3> <pre> ## Not run: ## see the active project proj_get() ## manually set the active project proj_set("path/to/target/project") ## build a path within the active project (both produce same result) proj_path("R/foo.R") proj_path("R", "foo", ext = "R") ## build a path within SOME OTHER project with_project("path/to/some/other/project", proj_path("blah.R")) ## convince yourself that with_project() temporarily changes the project with_project("path/to/some/other/project", print(proj_sitrep())) ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>usethis</em> version 2.1.6 <a href="00Index.html">Index</a>]</div> </body></html>