Fork me on GitHub
István Karaszi14:02:12

Shouldn’t there be a join-paths function in babashka.fs?


@UJSBQNUG6 This is implicitly already there in the form of:

(fs/file .. .. ..)


or (fs/path .. .. ..), If you want to have a string, call str on it

István Karaszi14:02:08

hmm, okay, that works

István Karaszi14:02:16

don’t you think it would be convenient to have such thing?


I don't see the need for it since it's already there

István Karaszi14:02:15

okay, I missed the fs/path one

István Karaszi14:02:19

thank you!

👍 2
István Karaszi15:02:19

Is there a way to display a formatted help for a dispatch table with babashka.cli?

István Karaszi15:02:58

cli/format-opts is great, but I cannot see how could I display the command table in a nice way


@UJSBQNUG6 For the command table it's not there (yet), I've done it manually so far


E.g. in neil: I print a global overview and then use format-opts to print the details for each subcommand

István Karaszi16:02:34

there is a bit of duplication here and there

István Karaszi16:02:15

but it works, thanks!


I suspect there won't be a single way that fits every subcommand need, but maybe it's worth a shot one day

István Karaszi16:02:30

that is fine, I thought there might be something but I am blind as I proved earlier 😄


no worries, keep asking away ;)


when using babashka.http as a library, is it possible to use a newer version of it or will the built-in always be used instead? It seems to be preferring the built-in version so a bb upgrade was a breaking change in our case.


yes, use require + :reload

🙏 2

For babashka.fs: Are you interested in a PR that would extend the zip function to allow more flexibility with relative paths? Some ideas in:thread:


Right now you must specify relative paths for entries that will be mirrored in the resulting zip. Specifically right now I'm trying to remove this babashka shell call to zip.

(shell {:dir "root-dir"}
  "zip" ""
Which takes the given file in the root-dir and puts them in a zip. Unfortunately zip cli calls aren't optimal for cross platform things. So one way to support this in fs is have the zip function take an option that essentially "relativizes" the paths when putting them in the zip.
(fs/zip "" ["root-dir/file1.txt"
  {:relativize-entry-paths "root-dir"})
Another more general option might be to allow a function to be passed to transform an entry to the path that will appear in the zip, ie
(fs/zip "" ["root-dir/file1.txt"
  {:entry-path (fn [p] (fs/relativize "root-dir" p))})
Another idea is to allow a map for the entries themselves, mapping the path on the filesystem to the path it will appear in the zip:
(fs/zip "" {"file1.txt" "path/for/file1.txt"
                     "file2.txt" "another/path/file2.txt"})


I sort of like the last option the best, but interested in any input. Also open to the idea that this is getting too fancy with zipping functionality for a general file library, and it should be somewhere else.


> Another more general option might be to allow a function to be passed to transform an entry to the path that will appear in the zip, I think this will be the most flexible option


but do I understand correctly that you just want to get rid of the parent directory, like in that issue?


I want to use a different directory as the parent directory, which I think is different


I have stuff/f1.txt and i want it as f1.txt in the zip


yes, this is what I mean with "elide parent directory" in the issue


you want to elide stuff in the zip


but a :path-fn or so would be good, then indeed you can call relativize


One thing I realized I missed is the case where a directory is specified as an entry. Presumably the path-fn in that case would return the entry path of the directory. And then the contents of that dir are all given a path relative to that in the zip


Maybe best to try out in an experimental PR or so


will do, thanks for the input!


@U064UGEUQ I went ahead and added both :root and :path-fn - it's released, see #C06MAR553


I will release a new bb tomorrow morning with this included as well


Awesome, thanks!