fix: make recipe name autocomplete less slow #604

Merged
decentral1se merged 4 commits from fix/567 into main 2025-08-24 07:24:48 +00:00
Owner

See #567. My proposal was #567 (comment).

Benefit along the way: it's now possible to autocomplete remote recipes.

See https://git.coopcloud.tech/toolshed/abra/issues/567. My proposal was https://git.coopcloud.tech/toolshed/abra/issues/567#issuecomment-25921. Benefit along the way: it's now possible to autocomplete remote recipes.
decentral1se added 3 commits 2025-08-18 08:15:06 +00:00
See #567
feat: include local recipes on auto-complete
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2e37c14fc4
decentral1se added this to the Abra v0.11.x project 2025-08-18 08:15:06 +00:00
decentral1se moved this to In Progress in Abra v0.11.x on 2025-08-18 08:15:56 +00:00
decentral1se requested review from 3wordchant 2025-08-18 17:33:17 +00:00
decentral1se requested review from p4u1 2025-08-18 17:33:17 +00:00
p4u1 reviewed 2025-08-18 18:57:24 +00:00
@ -39,3 +40,3 @@
// RecipeNameComplete completes recipe names.
func RecipeNameComplete() ([]string, cobra.ShellCompDirective) {
catl, err := recipe.ReadRecipeCatalogue(false)
catl, err := recipe.ReadRecipeCatalogue(true)
Member

Even when offline, I think it would be nice to "cache" the catalogue in memory. Otherwise everytime we hit it reads the recipe catalogue again. What do you think @decentral1se

Even when offline, I think it would be nice to "cache" the catalogue in memory. Otherwise everytime we hit <tab> it reads the recipe catalogue again. What do you think @decentral1se
Author
Owner

@p4u1 good idea, that does make a lot of sense. I can see we are doing multiple calls in some code paths. Should we maybe try something like https://github.com/kofalt/go-memoize for this? Otherwise, cobra does provide context, but it might be awkward putting that in / retrieving it elsewhere...

@p4u1 good idea, that does make a lot of sense. I can see we are doing multiple calls in some code paths. Should we maybe try something like https://github.com/kofalt/go-memoize for this? Otherwise, `cobra` does provide context, but it might be awkward putting that in / retrieving it elsewhere...
Author
Owner

I tried it out but I fear the situation that people then want a flag or some way to bust the cache or they don't even realise it is being cache and can't seem to get the latest catalogue values... I am gonna leave this off for someone smarter than me 🙃

I tried it out but I fear the situation that people then want a flag or some way to bust the cache or they don't even realise it is being cache and can't seem to get the latest catalogue values... I am gonna leave this off for someone smarter than me 🙃
decentral1se marked this conversation as resolved
p4u1 reviewed 2025-08-18 18:58:36 +00:00
@ -50,2 +57,4 @@
}
for _, recipeLocal := range localRecipes {
recipeNames = append(recipeNames, recipeLocal)
Member

Sweet!

Sweet!
decentral1se marked this conversation as resolved
decentral1se force-pushed fix/567 from 2e37c14fc4 to a30282e1c1 2025-08-24 07:17:18 +00:00 Compare
decentral1se force-pushed fix/567 from a30282e1c1 to 727753bd2e 2025-08-24 07:20:46 +00:00 Compare
decentral1se force-pushed fix/567 from 727753bd2e to 42dde0930d 2025-08-24 07:23:25 +00:00 Compare
decentral1se merged commit 42dde0930d into main 2025-08-24 07:24:48 +00:00
decentral1se deleted branch fix/567 2025-08-24 07:24:49 +00:00
decentral1se moved this to Done in Abra v0.11.x on 2025-08-24 07:28:30 +00:00
decentral1se removed this from the Abra v0.11.x project 2025-08-30 10:14:56 +00:00
Sign in to join this conversation.
No description provided.