heuermh / lick

LiCK, Library for ChucK
GNU General Public License v3.0
147 stars 21 forks source link

Add relative path in import.ck #8

Closed 01010101 closed 6 years ago

01010101 commented 6 years ago

Would be nice to modify import.ck to use a relative path when adding the library's ck files so import.ck can be called from anywhere.

// Get import.ck path me.dir() => string path;

// functional interfaces or functors, package fn Machine.add(path+"/lick/fn/BinaryFunction.ck");

heuermh commented 6 years ago

Thanks for the suggestion, @01010101!

When I run stuff with LiCK I'm running from the lick source directory and

$ chuck --loop &

in one terminal window and

$ chuck + import.ck
$ chuck + examples/foo.ck

in another. What is your use case, and how might this help?

01010101 commented 6 years ago

Hi. I also run chuck this way (tmux or screen window) but was thinking it would be useful to have some kind of utils or libs (incl. lick) in an external folder. This way I can refer to some of them from any working directory so I don't have to copy/duplicate those files nor have everything I'm working on at the same place, or even navigate directories. It just seemed more natural to me to do imports this way.

But, indeed, I can do the opposite and run chuck from that lib/utils folder, then manage paths within my ck files.

heuermh commented 6 years ago

Thanks, let's talk that through. You have

lick/import.ck
lick/lick/...
working/foo.ck

and you'd like to do

$ pwd
working

$ chuck --loop &
$ chuck + foo.ck

foo.ck:

Machine.add("../lick/import.ck");
<<<"ok">>>;

or perhaps

$ chuck --loop &
$ chuck + ../lick/import.ck foo.ck

?

01010101 commented 6 years ago

Yeah, that's the idea