importpw / import

`import` is a simple and fast module system for Bash and other Unix shells
https://import.sh
MIT License
338 stars 10 forks source link

Separate downloading+caching from 'sourcing' #39

Closed isotes closed 4 years ago

isotes commented 4 years ago

Aside from 'sourcing' library scripts, it would be great to reuse the download+cache infrastructure for other files, e.g., binaries or scripts in other languages (Ruby, ...) or even simple data files that are used as a dependency. While binaries provide their own challenges regarding the support for different platforms (i.e. having alternate versions) that might be overkill for this project, simply separating the download+cache step from the source step would be already very helpful. I would propose having an additional function next to import, e.g., name import_file that performs the download+cache step and returns the local path to make something like this possible:

ruby "$(import_file https://example.com/my-cool-ruby-script)"
TooTallNate commented 4 years ago

This is actually already implemented. You need to set print=1 variable when invoking the import function, like seen here.

I agree though that moving into a separate function would be a cleaner approach. Perhaps we could add import_file and deprecate the print=1 functionality. PR welcome if you'd like to take a stab at it.