R: Create 'cff' object

cff_create {cffr} | R Documentation

## Create `cff` object

### Description

Create a `cff` object from a given source for further manipulation. Similar to `cff_write()`, but returns a object rather than writing directly to a file. See Examples.

### Usage

    cff_create(
      x,
      keys = list(),
      cff_version = "1.2.0",
      gh_keywords = TRUE,
      dependencies = TRUE
    )

### Arguments

`x` | The source that would be used for generating the `cff` object. It could be: A missing value. That would retrieve the DESCRIPTION file on your in-development package. An existing `cff` object, The name of an installed package (`"jsonlite"`), or Path to a DESCRIPTION file (`"*/DESCRIPTION*"`).
`keys` | List of additional keys to add to the `cff` object. See Details.
`cff_version` | The Citation File Format schema version that the `CITATION.cff` file adheres to for providing the citation metadata.
`gh_keywords` | Logical `TRUE/FALSE`. If the package is hosted on GitHub, would you like to add the repo topics as keywords?
`dependencies` | Logical `TRUE/FALSE`. Would you like to add the of your package to the `reference` key?

### Details

It is possible to add additional keys not detected by `cff_create()` using the `keys` argument. A list of valid keys can be retrieved with `cff_schema_keys()`.

Please refer to Guide to Citation File Format schema version 1.2.0. for additional details.

If `x` is a path to a DESCRIPTION file or `inst/CITATION`, is not present on your package, cffr would auto-generate a `preferred-citation` key using the information provided on that file. On

### Value

A `cff` list object.

### See Also

Guide to Citation File Format schema version 1.2.0.

`vignette("cffr", "cffr")`

Other core functions: `cff_validate()`, `cff_write()`, `cff()`

### Examples

    # Installed package
    cff_create("jsonlite")

    # Demo file
    demo_file <- system.file("examples/DESCRIPTION_basic", package = "cffr")
    cff_create(demo_file)

    # Add additional keys

    newkeys <- list(
      message = "This overwrites fields",
      abstract = "New abstract",
      keywords = c("A", "new", "list", "of", "keywords"),
      authors = list(cff_parse_person("New author"))
    )

    cff_create(demo_file, keys = newkeys)

    # Update a field on a list - i,e: authors, contacts, etc.
    # We are adding a new contact here

    old <- cff_create(demo_file)

    new_contact <- append(
      old$contact,
      list(
        cff_parse_person(person(
          given = "I am",
          family = "New Contact"
        ))
      )
    )

    cff_create(demo_file, keys = list("contact" = new_contact))

[Package cffr version 0.2.1 Index]