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

Investigate consequences of empty flags #3

Closed
psolymos opened this issue Apr 26, 2022 · 1 comment
Closed

Investigate consequences of empty flags #3

psolymos opened this issue Apr 26, 2022 · 1 comment

Comments

@psolymos
Copy link
Member

psolymos commented Apr 26, 2022

E.g. one can type it incorrectly: Rscript index.R -- test instead of Rscript index.R --test.

Is this somehow preventable?

  • Should we remove leading spaces for flags? -- no b/c that would leave the script invalid, and we cannot differentiate key from value
  • Should this be an error? -- YES
  • Should it be silently ignored? -- no b/c that would leave the script invalid
@psolymos
Copy link
Member Author

Using Gitpod, we can verify that an empty flag is dangerous. --value ok works fine:

Rscript test.R --value ok

Loading required package: utils
Tracing function "install.packages" in package "utils"
List of 6
 $ trials     : int 5
 $ dataset    : chr "demo-data.csv"
 $ cores      : int 1
 $ user       :List of 1
  ..$ name: chr "demo"
 $ description: chr "This is a multi line\ndescription."
 $ value      : chr "ok"
 - attr(*, "trace")=List of 2
  ..$ kind : chr "merged"
  ..$ value:List of 2
  .. ..$ :List of 2
  .. .. ..$ kind : chr "file"
  .. .. ..$ value: chr "/workspace/rconfig/inst/examples/rconfig.yml"
  .. ..$ :List of 2
  .. .. ..$ kind : chr "args"
  .. .. ..$ value: chr "--value ok"
 - attr(*, "class")= chr "rconfig"

--value ok leaves a trace but sets no value:

Rscript test.R -- value ok

Loading required package: utils
Tracing function "install.packages" in package "utils"
List of 5
 $ trials     : int 5
 $ dataset    : chr "demo-data.csv"
 $ cores      : int 1
 $ user       :List of 1
  ..$ name: chr "demo"
 $ description: chr "This is a multi line\ndescription."
 - attr(*, "trace")=List of 2
  ..$ kind : chr "merged"
  ..$ value:List of 2
  .. ..$ :List of 2
  .. .. ..$ kind : chr "file"
  .. .. ..$ value: chr "/workspace/rconfig/inst/examples/rconfig.yml"
  .. ..$ :List of 2
  .. .. ..$ kind : chr "args"
  .. .. ..$ value: chr "-- value ok"
 - attr(*, "class")= chr "rconfig"

psolymos added a commit that referenced this issue Apr 27, 2022
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