els0r/goProbe

Rework / update bash autocompletion

fako1024 opened this issue · 4 comments

After the v4 release it is highly likely that there are a few things missing from the bash autocompletion we have / had in place (untested, but likely).
In addition there is an OSAG-specific piece of code in pkg/util regarding network tunnels (which seems to be solely used for bash autocompletion) that uses an OSAG build tag (and by default does nothing). IMHO we should get rid of all non-public code in this repo (or write it in a way that it can work everywhere / for everyone).

DoD

  • Rework / check bash autocompletion to cover all current tools & features
  • Remove (or rework) pkg/util

@els0r What are your thoughts on this one? I do fully understand that you might want the tunnel interface completion for OSAG, but maybe that's something that others are interested in, too. Can that be generalized maybe?

els0r commented

@els0r What are your thoughts on this one? I do fully understand that you might want the tunnel interface completion for OSAG, but maybe that's something that others are interested in, too. Can that be generalized maybe?

Heya. I've raised this internally as well. And had a brief look at auto-completion. Depending on how you want to see it, the completion half works (or is half working).

We could have third parties register actions upon interface resolution: meaning by default, only the name will be completed. If an action is compiled into the binary with a build tag, additional actions can be triggered (such as hostname resolution for tunnel interfaces).

Sounds good, although I don't think we'll need build tags for that. I suggest to do as you say (support autocomplete on names (you might be able to use the existing facilities to get all interfaces from slimcap, which is a lot faster that net.GetInterfaces()) and allow everyone to register additional callbacks using e.g. a global function like RegisterAutocompleteCallback(fn func(...) error) that can act upon the instance and that can be used to add whatever functionality is needed (similar to what prometheus does).

els0r commented

Thanks for the suggestions. I'm on board with the proposal. Maybe @silvanbitterli can have a look.