On Thursday, 11 August 2016 at 18:47:05 UTC, Jonathan Marler
wrote:
The use case is you have a collection of D scripts within the
same directory subtree (maybe a git repo) that all share some
common configuration. Maybe they all require extra search paths
to find source/libraries, or they all throw exceptions to the
user and should be compiled with debug symbols so exceptions
print their full stacktrace, etc. Rather then requiring the
user to call the script in a particular way or wrapping all the
scripts with yet another tool, what about adding support in
rdmd for configuration files? The configuration file could
live in any parent directory of the script being ran:
FileSystem:
/a/b/c/myscript.d
Shell:
/a/b/c> rdmd myscript.d
rdmd checks for /a/b/c/rdmd.config
rdmd checks for /a/b/rdmd.config
rdmd checks for /a/rdmd.config
rdmd checks for /rdmd.config
The rdmd.config file would apply to all rdmd scripts in all
subdirectories on the file system. It works similar to how git
determines whether or not it lives in a repository (searches
all parent directories for the .git directory).
Additionally, allowing rdmd to be configured through files
makes more complicated configurations more reasonable. For
example, if your scripts depend on a dub package, you could do
this easily in a configuration file, whereas doing this on the
command line would be a nightmare.
Supporting this type of configuration could easily be
implemented in a wrapper around rdmd (rdmdc?), however, if this
idea is generally useful then it should be added to rdmd itself
so everyone benefits. The question is, is this feature general
and useful enough to justify adding to rdmd itself, or is this
only useful in rare cases meaning it should live inside an rdmd
wrapper?
In my opinion, adding this complexity to rdmd is overkill. When
you need to use this, IMHO, you should write a little shell
script that calls rdmd passing the correct arguments. It's very
easy, just a couple of lines of shell script. Maybe even a
one-liner.
In file rdmd_wrapper.sh:
rdmd -my-special -command-line -parameters $*
When you call it this way:
./rdmd_wrapper mymodule.d
It will execute this:
rdmd -my-special -command-line -parameters mymodule.d
If you need the same configuration really often, you can add the
wrapper to the path, so you can call it from everywhere.
But this is just my opinion, many may disagree.