Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing named ... through docopt #43

Open
lorenzwalthert opened this issue Sep 16, 2020 · 1 comment
Open

passing named ... through docopt #43

lorenzwalthert opened this issue Sep 16, 2020 · 1 comment

Comments

@lorenzwalthert
Copy link

lorenzwalthert commented Sep 16, 2020

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 ... matches unnamed arguments here, but I'd like to pass named ones.

@lorenzwalthert lorenzwalthert changed the title passing ... through docopt passing named ... through docopt Sep 16, 2020
@lorenzwalthert
Copy link
Author

Maybe we can extend the syntax? like ...<dots> to match named arguments, as an extension to <dots>...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant