chmln / sd

Intuitive find & replace CLI (sed alternative)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any plan to publish as a library crate?

fujidaiti opened this issue · comments

I think it would be nice to be able to use the functionality of sd from Rust code. Yes, we can do it with std::process::Command or something, but it is not type safe.

What is your meaning, please? Do you mean that we should publish it as a Rust library?

I would be happy if this were the case. For example, std::fs::create_dir could be used to do the same thing as the mkdir command, but inside Rust code. However, there is no straightforward way to do the same thing in Rust as the sd or sed commands, as far as I know. So it would be useful if the sd command could be a function (like sd::replace(...)) and published as a library.

I think it is a good idea... @CosmicHorrorDev do you think so? I think I can work on it. It sounds funny for me.

I could see it being useful. I think go ahead and start on it if you want 👍

I don't think converting sd into a library is a good move as it introduces the burden of maintaining a stable public API, making future changes more cumbersome and necessitating in-depth versioning management.

The regex crate already offers a better solution for finding and replacing, the only thing that sd adds on top of it as a library would be file mmaping.

The crate maintainers will need to document the API and add additional tests beyond what's typical for CLI usage
This also opens the door for feature creep as library users will request more general features.

I personally don't think it's worth it for the future of the crate.

Now that the last release is out I think I have to say that I changed by mind and don't think we should publish a library crate any time in the near future. There's too many ongoing and planned changes going on in sd right now, so I don't foresee a stable usable interface that won't be a pain to both depend on and maintain

This may change in the future, but I'll be closing this for now