chmln / sd

Intuitive find & replace CLI (sed alternative)
MIT License
5.72k stars 136 forks source link

Example implementation for the filters #282

Open dev-ardi opened 9 months ago

dev-ardi commented 9 months ago

There's still a lot to do and think. This is just a draft to have an example to think about and work on.

This just is a list of composable filters that fit into another. This is really extensible, but there are a few things left to think.

There are many optimizations possible with this model.

I don't like having possible failures inside of the filters, everything should have been figured out by this time, but I've implemented it just in case

CosmicHorrorDev commented 9 months ago

I'll look at this more after #265 gets merged since I'm assuming that will change at least some of this PR

dev-ardi commented 9 months ago

@CosmicHorrorDev

will change at least some of this PR

Not really. This is atomic and only the "filter" part. There's still so much to do.

CosmicHorrorDev commented 9 months ago

I can take a look after I'm no longer sick

dev-ardi commented 9 months ago

Get better soon!

CosmicHorrorDev commented 8 months ago

Sorry for taking so long to give feedback

I think the main fundamental thing that will cause problems and have to be addressed is how to handle streaming in this model. Like in the case of something like

$ sd --pretend-we-have-a-line-mode 'bar' 'baz'
foo
bar
baz <-- output by `sd`

we need to be able to stream the output line by line which I think means that we'll need to have an api that looks more like the std::io apis where you dealing more with reading and writing and different layers can allocate as needed

Some various other thoughts:


All that out of the way that doesn't mean we need something that can fit all of those needs now, but I think it does limit how Filter can be designed