Fork me on GitHub
#babashka
<
2021-07-20
>
martinklepsch10:07:32

@borkdude is there a link for that already?

martinklepsch10:07:50

super eager to play around with those more, seems really handy

grazfather15:07:46

By my math it’s in about 2 hours?

borkdude15:07:59

2 hours and 17 minutes

grazfather18:07:05

I had to duck out near the end but it was good!

grazfather18:07:26

and yes the p after coffeep was indeed because i was comparing it to a non-parallel version

borkdude18:07:39

thanks for attending

grazfather18:07:54

I learned some new things

borkdude20:07:48

Here are the slides: https://twitter.com/borkdude/status/1417562502985101321 Youtube video will probably be up tomorrow

Cora (she/her)22:07:05

I noticed fs didn't have anything equivalent to basename path suffix sooooo https://github.com/babashka/fs/pull/28

borkdude22:07:10

@corasaurus-hex (first (split-ext f))?

Cora (she/her)22:07:32

if you want to remove a specific suffix, you have to do tests there

Cora (she/her)22:07:54

or if you want to remove an extension with multiple dots

Cora (she/her)22:07:59

like .html.template

Cora (she/her)22:07:57

it's a common enough need that it's included on the command-line in posix systems ¯\(ツ)

Cora (she/her)22:07:40

someone in #clojure wanted to remove ".md" from the ends of filenames and I thought "I'll bet fs has basename which would be really good at this" and I was surprised to find it didn't

Cora (she/her)22:07:55

@borkdude the single arity version of that function is indeed exactly what you put, though

borkdude22:07:06

is base-name the posix term for this?

Cora (she/her)22:07:28

basename will give you the last segment of a path, what fs calls file-name

Cora (she/her)22:07:37

it will optionally remove a suffix

borkdude22:07:58

if I wanted to remove the .md extension, I'd probably write (str/replace s #"\.md$" "") ;)

Cora (she/her)22:07:25

in which case, rejecting the PR is a good idea

borkdude22:07:28

we could perhaps name this function remove-ext or so.

borkdude22:07:39

I'll think about it some more, it's too late for me now :)

Cora (she/her)22:07:49

but it's not exactly removing the ext, because it also removes the path like basename does

Cora (she/her)22:07:35

which is the big trick

borkdude22:07:37

(map #(first (split-ext %)) ...) would probably also work in the majority of cases

Cora (she/her)22:07:09

if you're sure they all have the right extension already, definitely

Cora (she/her)22:07:17

if you'e already globbing or something, you'd know that for sure

borkdude22:07:59

it's probably better to open an issue or discussion first to see what are the use cases for such a function

borkdude22:07:14

and then record the arguments there first

borkdude22:07:26

and see how it composes with the rest

Cora (she/her)22:07:11

is the criteria for addition "this is work many people would have to do when working with files"? or is it "this is significantly difficult enough to do when working with files so we'll include it"?

borkdude22:07:40

I'm not against including new functions, but taking on new functions also means maintaining them forever, so I'd like to first see some thinking before coding

borkdude22:07:32

and having such an issue open also means other people over time can post feedback on it

borkdude22:07:35

and give it some time

Cora (she/her)22:07:50

I'll open an issue and link to the PR

Cora (she/her)22:07:47

thanks for the feedback simple_smile

borkdude22:07:58

btw, raynes/fs calls this function basename, which I found confusing since some other libs had this function and stripped the extension.

borkdude22:07:29

but I now see that raynes/fs has an option to strip the extension. which we could also do in file-name

Cora (she/her)22:07:39

I was thinking that might be appropriate as well

Cora (she/her)22:07:45

and that mirrors basename

borkdude22:07:12

ok, good to record the conversation in an issue

Cora (she/her)22:07:15

I like the idea of having it be able to automatically figure out the extension and remove it

Cora (she/her)22:07:24

and also giving it a suffix to remove

Cora (she/her)22:07:38

because removing a suffix is actually more powerful than just removing an extension

lukasz22:07:36

I almost opened a PR for this (it was adding an option to strip a suffix) but realized that fs/file-name and fs/extension basically give you all the building blocks. After reviewing the code and how we use babashka.fs in majority of the cases we wanted to full name (as in: with extension), so I dropped it.

Cora (she/her)23:07:13

do you think you could talk about your experience on the issue? it'd be nice to have things collected there, even if ultimately against

Cora (she/her)23:07:23

or I could quote you if you'd like?

lukasz14:07:22

Looks like @borkdude already did :-)

lukasz14:07:09

I will follow up there too with some additional comments :thumbsup:

partywombat 2
Cora (she/her)22:07:42

do your worst 😉