Skip to contents

A class and utility methods for reading, creating and holding CFF information. See cff_class to learn more about cff objects.

Usage

cff(path, ...)

Arguments

path

[Deprecated] path is no longer supported, use cff_read_cff_citation() instead.

...

Named arguments to be used for creating a cff object. If no arguments are supplied (the default behavior), a minimal valid cff object is created.

Value

A cff object. Under the hood, a cff object is a regular list object with a special print method.

Details

cff() would convert _ in the name of the argument to -, e.g. cff_version = "1.2.0' would be converted to cff-version = "1.2.0'.

Valid parameters are those specified on cff_schema_keys():

  • cff-version

  • message

  • type

  • license

  • title

  • version

  • doi

  • identifiers

  • abstract

  • authors

  • preferred-citation

  • repository

  • repository-artifact

  • repository-code

  • commit

  • url

  • date-released

  • contact

  • keywords

  • references

  • license-url

See also

Other core functions of cffr: cff_create(), cff_modify(), cff_validate()

Examples

# Blank cff
cff()
#> cff-version: 1.2.0
#> message: If you use this software, please cite it using these metadata.
#> title: My Research Software
#> authors:
#> - family-names: Doe
#>   given-names: John

# Use custom params
test <- cff(
  title = "Manipulating files",
  keywords = c("A", "new", "list", "of", "keywords"),
  authors = as_cff_person("New author")
)
test
#> title: Manipulating files
#> keywords:
#> - A
#> - new
#> - list
#> - of
#> - keywords
#> authors:
#> - family-names: author
#>   given-names: New
# \donttest{
# Would fail
cff_validate(test)
#> ══ Validating cff ══════════════════════════════════════════════════════════════
#>  Oops! This <cff> has the following errors:
#> * cff["cff-version"]: is required
#> * cff.message: is required
# }

# Modify with cff_create
new <- cff_create(test, keys = list(
  "cff_version" = "1.2.0",
  message = "A blank file"
))
new
#> cff-version: 1.2.0
#> message: A blank file
#> title: Manipulating files
#> authors:
#> - family-names: author
#>   given-names: New
#> keywords:
#> - A
#> - new
#> - list
#> - of
#> - keywords

# Would pass
cff_validate(new)
#> ══ Validating cff ══════════════════════════════════════════════════════════════
#>  Congratulations! This <cff> is valid