carapace-sh / carapace

command argument completion generator for spf13/cobra
https://carapace.sh
Apache License 2.0
321 stars 8 forks source link

API: Add a CacheF() function to control completion cache refresh #887

Closed maxlandon closed 1 year ago

rsteube commented 1 year ago

Need to give this some thinking when i got the time. I feel like this should already be doable with the timeout (e.g. zero duration) and key arguments. If anything i'd probably opt for a custom error returned by the key function :thinking: .

maxlandon commented 1 year ago

You might very well be right, and its probable that I've come to open this PR just because I over complicated my own use of the cache in some instances.

So feel free to close if in a few days you still have no clues on this, as it might just be me trying to solve a non-existing problem.

maxlandon commented 1 year ago

Two other things: 1 - I saw you started leveraging lexers for command-line consumption, great idea, curious to see what wonders you'll do with this. 2 - I tried to attack this infamous cobra global comp map, here: https://github.com/spf13/cobra/pull/2012#issuecomment-1669585151, if you have anything you'd like to contribute in order to pull this chard out of everyone's foot, that will be my joy !

rsteube commented 1 year ago

Yes, zero timeout duration seems to do the trick. Writing a lexer is actually something i wanted to avoid, but it is needed for Split.