mschubert / ebits

R bioinformatics toolkit incubator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In io module, automatically evaluate module_file on given path

mschubert opened this issue · comments

This would make sure that read/write is always relative to the script the call resides in.

Any downsides?

The downside is that you sometimes want to use files relative to PWD. In fact, I’d guess that this is the most common use-case for data files, definitely always with user-provided files. Consider:

sys = mod::use(klmr/sys)

sys$run({ 
    io = mod::use(ebits/io)
    args = sys$cmd$parse(arg('file', 'input file'))
    sys$printf('%s', summary(io$read_table(args$file)))
})

NB: this issue is probably 2 years old, I just copied them from the other repository and they will need to be cleaned up further. We didn't have a sys module back then.

And yes, this is true for command-line interfaces, but usually not for modules providing API access to data. But you're right, the better way to simplify module-relative file access is probably https://github.com/klmr/modules/issues/132