Skip to content

any way to know if entry is default? #23

@r2evans

Description

@r2evans

The attr(,"config") always points to the name requested, regardless of inheritance or use of the "default" value. If inherited, then there is the $inherits value in the list, but if the name is not found then the default entry is returned with no indication that it is being used.

Short of using names(yaml::yaml.load_file("...")), is there a way to determine if the named account is not present?

config::get(config = "", file = authfn, use_parent = FALSE)
# $inherits
# [1] "localpg"
# attr(,"config")
# [1] ""
# attr(,"file")
# [1] "C:\\Users\\r2\\.config.yml"

Perhaps something like attr(,"defaultused") <- TRUE could be a simple start. An extreme solution might provide a vector of inherited names:

default:
  user: joe
bob:
  user: bob
def1:
  inherits: bob
def2:
  inherits: def1
def3:
  inherits: def2
config::get(config = "def3", file = authfn, use_parent = F)
# $user
# [1] "bob"
# $inherits
# [1] "def2"
# attr(,"config")
# [1] "def3"
# attr(,"file")
# [1] "C:\\Users\\r2\\.config.yml"
# attr(,"inherited")
# [1] "def2" "def1" "bob"

(I realize having the default value is important, and that one intent is for it to always return something if the file is present and the file is structured correctly with at least a default: entry. I'm not suggesting changing that.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions