manifest_cli: Run the manifest generation command line interface (CLI).

View source: R/cli.R

manifest_cliR Documentation

Run the manifest generation command line interface (CLI).

Description

Generate a manifest CSV from a directory of files from the command line. This function is meant to be run with Rscript, not to be called interactively. It reads the command line arguments, parses them, and calls write_manifest_from_dir. It is the engine behind the standalone make_manifest.R script that ships with the package (see manifest_script).

Usage

manifest_cli(args = commandArgs(trailingOnly = TRUE))

Arguments

args

character vector. The command line arguments. Defaults to the arguments actually passed to the R script (commandArgs(trailingOnly = TRUE)). You normally do not pass this; it exists to make the function testable.

Details

Supported arguments (each flag can be given as --flag value or as --flag=value):

  • --dir <path>: The directory containing the data files (required).

  • --out <path>: The path of the CSV file to write the manifest to (required).

  • --url-base <url>: Optional base URL used to derive the download URL of every file, as paste0(url_base, path).

  • --help: Print usage information and exit without generating anything.

A leading --args or -- marker (used by Rscript to separate command line arguments from R options) is ignored, so both the one-liner form and the script form shown in the examples work.

Value

The generated manifest as a data.frame, invisibly, or NULL if --help was given.

Examples

  ## Not run: 
  # One-liner from the shell (no script file needed):
  Rscript -e 'pkgfilecache::manifest_cli()' --args --dir ~/mydata --out files.csv

  # Same thing using the standalone script shipped with the package
  # (--url-base is optional and derives the download URLs):
  Rscript "$(Rscript -e 'cat(pkgfilecache::manifest_script())')" --dir ~/mydata --out files.csv
  
## End(Not run)


pkgfilecache documentation built on Sept. 1, 2026, 1:08 a.m.