R/parse_help.R
cmd_help_flags_similar.Rd
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))#> missplld #> "misspelled"command_flags <- c("long-flag-name") flags <- c("long_flag_naee") cmd_help_flags_similar(command_flags, flags, .fun = ~{gsub("-", "_", .x)})#> long_flag_naee #> "long_flag_name"#> NULL