Closed bangedorrunt closed 3 years ago
That is a good question, I think it should be fairly simple to introduce two new consumers, one a combination consumer and the other a conditional consumer:
combine(producer1, producer2)
And:
try(producer1, producer2)
"combine" would just combine the results of two or more producers, and "try" would use the first, then if no results occur will try the second, and then the third if provided etc.
Thanks for the ideas!
Resolved in https://github.com/camspiers/snap/commit/e19696700a6188cc145ba587de131195d1731fc8
You can now do something like:
snap.run {
producer = snap.get'consumer.fzf'(
snap.get'consumer.try'(
snap.get'producer.git.file',
snap.get'producer.ripgrep.file'
),
),
select = snap.get'select.file'.select,
multiselect = snap.get'select.file'.multiselect,
views = {snap.get'preview.file'}
}
I hope this example also helps to illustrate the flexibility of the producer consumer pattern.
Wow, that's great. I really like the try
and combine
idea. Cheers!
Hi, I'm wondering if it is possible to make snap automatically fall back to file searching if the working dir is not git project.