R: Utility functions for the active project

proj_utils {usethis} | R Documentation

## Utility functions for the active project

### Description

Most `use_*()` functions act on the active project. If it is unset, usethis uses rprojroot to find the project root of the current working directory. It establishes the project root by looking for a `.here` file, an RStudio Project, a package `DESCRIPTION`, Git infrastructure, a `remake.yml` file, or a `.projectile` file. It then stores the active project for use for the remainder of the session.

### Usage

    proj_get(quiet = FALSE)

    proj_set(path = ".", force = FALSE, quiet = FALSE)

    proj_path(..., ext = "")

### Arguments

`quiet` | Logical. Whether to announce project activation.
`path` | Path to set.
`force` | If `TRUE`, use this path without checking the usual criteria. 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 DESCRIPTION file.
`...` | character vectors, if any values are NA, the result will also be NA.
`ext` | An optional extension to append to the generated path.

### Details

In general, end user code should not call `usethis::proj_get()`, `usethis::proj_set()`, or `usethis::proj_path()`. 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 rprojroot or its simpler companion, here, to programmatically detect a project and build paths within it.

### Functions

- `proj_get`: Retrieves the active project and, if necessary, attempts to set it in the first place.

- `proj_set`: Sets the active project.

- `proj_path`: Builds a path within the active project. Thin wrapper around `fs::path()`.

### See Also

Other project functions: `proj_sitrep`

### Examples

    ## 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")

    ## End(Not run)

[Package usethis version 1.4.0 Index]