docopt.R
docopt.R copied to clipboard
passing named ... through docopt
Thanks for this useful package. I'd like to pass arguments to docopt for which the name have not explicitly defined (becauuse they are dynamic). In R, we know the concept of an ellipse (...). I imagine it to work similar to this:
./inst/bin/style-files --style_pkg=1 --stle_fun=3 --key=1 --value2=67 f1 f2
But I get an error.
Error: style files.
Usage:
style_files [--style_pkg=<style_guide_pkg>] [--style_fun=<style_guide_fun>] <files>...
Options:
--style_pkg=<style_guide_pkg> Package where the style guide is stored [default: styler].
--style_fun=<style_guide_fun> The styling function in style_pkg [default: tidyverse_style].
Execution halted
Is there any way to do this? Or can you maybe expose the parser so I can parse the arguments without matching them to the docs?
Here is my script:
#!/usr/bin/env Rscript
'style files.
Usage:
style_files [--style_pkg=<style_guide_pkg>] [--style_fun=<style_guide_fun>] <files>...
Options:
--style_pkg=<style_guide_pkg> Package where the style guide is stored [default: styler].
--style_fun=<style_guide_fun> The styling function in style_pkg [default: tidyverse_style].
' -> doc
saveRDS(commandArgs(), 'cmd.rds')
I note that
Maybe we can extend the syntax? like ...<dots> to match named arguments, as an extension to <dots>...?