simpleroptions (version 0.2.0)

OptionsManager: OptionsManager

Description

Create an OptionsManager object, to easily manage an option file to be used in your functions and scripts.

Usage

OptionsManager(options_path, default_options = list(), permissions = "600",
  auto_save = TRUE, strict = FALSE, verbose = FALSE)

Arguments

options_path

the path to the option file. For script I recommend to use something like "./option_file.json", for R packages something like "~/.package_name/option_file.json"

default_options

this should be a list containing the default values to use when creating an options file.

permissions

a string containing the permissions to apply to the file. It defaults to "600"

auto_save

whether to save automatically the option file when you change an option value. It defaults to TRUE

strict

whether only option names appearing in "default_options" should be accepted or not. It defaults to FALSE, but I recommend to set it to TRUE if you are using simpleroptions in a package.

verbose

whether to show some information messages or not. It defaults to FALSE.

Value

an "OptionsManager" R6 object

Examples

Run this code
# NOT RUN {
exOpt <- OptionsManager(
  options_path = "./example_options.json",
  default_options = list(
    image_directory = ".",
    image_extension = ".jpg"
    )
)

# You can modify the values in the options file using the `set()` method
exOpt$set(image_directory = "images",
          image_extension = ".png")
          
# }

Run the code above in your browser using DataLab