| cmd_help_flags_similar | R Documentation |
Suggest alternative name by minimizing Levenshtein edit distance between valid and invalid arguments
cmd_help_flags_similar( command_flag_names, flags, .fun = NULL, distance_cutoff = 3L )
command_flag_names |
character vector of valid names (can be output of |
flags |
a vector names correspond to values to be checked against |
.fun |
optional function to apply to |
distance_cutoff |
Levenshtein edit distance beyond which to suggest ??? instead of most similar argument (default = 3). Setting this too liberally will result in nonsensical suggestions. |
named vector where names are names from flags and their values are the suggested best match from command_flag_names
# with a flagsList, need to pass names()
flagsList <- list("output" = "somevalue", "missplld" = "anotherValue")
cmd_help_flags_similar(c("output", "misspelled"), names(flagsList))
command_flags <- c("long-flag-name")
flags <- c("long_flag_naee")
cmd_help_flags_similar(command_flags, flags, .fun = ~{gsub("-", "_", .x)})
# returns NULL if no errors
cmd_help_flags_similar(c("test"), "test")