Use Cobra framework with a variable param that comes before subcommand

I’m a new go developer, although I’ve been writing code in other languages for a few decades.

I’m looking at writing something like “kubectl”, but where there is always a first parameter representing the context, followed by a subcommand and then option flags.

It’s also possible that just the context name is present, with no subcommand, which would represent an “implied” subcommand which would print the list of context names where the given context name is a substring.

I’m not certain how to construct something like this with Cobra. Are there some reasonable ways to modify the default structure to get to this?