Consolidate the logic used to generate the command completion category into one place. This is shared by CommandCompletionModel, HelpCompletionModel, and BindCompletionModel.