Skip to content

Possibility to source a script and passing arguments to it #25

@blaiseli

Description

@blaiseli

Is it possible to pass arguments to a script using docopt when sourcing this script?

I tried redefining commandArgs as suggested in http://stackoverflow.com/a/14526329/1878788, but this fails.

for instance, my docopt text (named doc) contains the following rule:

-o, --out_dir <out_dir>  out_dir

If, in my interactive R session, I redefine commandArgs as follows:

 commandArgs <- function() {c("--out_dir", "interactive_session")}

and then source my script, when I examine the result of docopt(doc), I see the following:

$`--out_dir`
NULL

Any help appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions