Reconsider how global tools are specified

#557 · open · 0 comments

View on GitHub ↗

dazuma

Currently the rules for tool file lookup for the `toys` binary are effectively as follows: * `.toys.rb` and `.toys/` (the `toplevel_tool_file_name` and `toplevel_tool_dir_name`) in the current directory and ancestor directories from the current directory down to but not including the home directory * `$HOME/.toys.rb` and `$HOME/.toys/` (always searched) * `/etc/.toys.rb` and `/etc/.toys/` (always searched) * builtins (always searched) This has issues: * `$XDG_CONFIG_DIR` is not included. * It's awkward and inconsistent that `.toys.rb` and `.toys/` normally contain directory-specific tools (or at least tools that are part of the directory ancestry path) for all directories, *except* `/etc` and `$HOME` where they are global and can be reached from anywhere. I think this needs to be tightened. One proposal: * `.toys.rb` and `.toys/` in the current directory and ancestor directories from the current directory down to the home directory, *including* in the home directory *if* it is in the ancestry. * `$XDG_CONFIG_DIR/toys` (similarly does *not* use the `toplevel_tool_file_name` and `toplevel_tool_dir_name`) * `/etc/toys` (note does *not* use the `toplevel_tool_file_name` and `toplevel_tool_dir_name`) That is, the `toplevel_tool_file_name` and `toplevel_tool_dir_name` (`.toys.rb` and `.toys/`) now *consistently* apply *only* to directory-specific and directory-ancestry-specific tool lookup. So for example, if you call `toys` from `/var/local`, you will *not* find `$HOME/.toys.rb` or `/etc/.toys.rb`. But you will find tools in `/etc/toys` and `$XDG_CONFIG_DIR/toys`.

Comments