-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get the filename without an extension/suffix #29
Comments
Alternatives when we go for 4: Comment in Slack:
|
|
To add to that: I think it would be reasonable addition if My initial assumption was that's how things will be named in But as I mentioned in my original comment in Slack: all the building blocks are present, and starting with a help namespace in your own code might be the way to go (that's how my team approaches things: we have a whole layer of code on top of cognitect/aws-api or carmine, but it wouldn't make sense to merge that in into base libraries. Just some food for thought of course! |
It might be worth talking about why a thing gets included in babashka/fs, too. I tried to think through the categories of needs a library like this can fill and it seems like there are at least three (let me know if you can think of more!):
I think babashka/fs definitely does 1 and 3. It seems like the trouble here is that this code sort of falls into category 2. Can we make a good argument for 2? I think so. If people commonly need to do it exactly what a function does, and it's filesystem handling, then it makes sense to have it maintained in one place. It saves quite a bit of labor over time and allows babashka scripts to be shorter and not duplicate behavior from script to script. On top of that, it reveals the intention of the code more to see However, this argument rests on whether this is something people commonly need to do, which I don't know how to show either way. It's common enough that it's included in POSIX shells but that also might be because removing the suffix from a file is so much more difficult in POSIX shells (which would be 3, not 2). Is this a common need? I certainly have used it to remove suffixes in the past in Ruby, but ever using isn't the same as commonly using. |
Oops, I think it maybe should. Perhaps it won't be really breaking if we fixed that. Suffix removal. Up for discussion. |
Would that work with multiple extensions? So like |
We can make it work with |
awesome! I was just typing up a comment on why that would work better 😄 |
I'd guess that |
And at that point it's just string handling and not really extension removal, so not really fitting for this library. |
I updated the PR to do strip-ext. I went with two positional arguments instead of making the second one an options map. Let me know if you feel strongly about that one, it just felt weird while I was implementing. |
I fixed the PR to with your comments. Let me know what you think. |
Looks like it was merged! |
Linux includes a handy function called basename which lets you get a file name from a path and optionally remove a suffix at the same time. Is this something
babashka.fs
should include?I have already opened #28 for this but it should be considered a WIP when/if it's decided what should be included.
Some possible options:
Looking for input and thoughts from the community, thanks!!
The text was updated successfully, but these errors were encountered: