cmd_help_flags_similar {cmdfun} | R Documentation |
Suggest alternative name by minimizing Levenshtein edit distance between valid and invalid arguments
Description
Suggest alternative name by minimizing Levenshtein edit distance between valid and invalid arguments
Usage
cmd_help_flags_similar(
command_flag_names,
flags,
.fun = NULL,
distance_cutoff = 3L
)
Arguments
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. |
Value
named vector where names are names from flags
and their values are the suggested best match from command_flag_names
Examples
# 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")