The output logic should all be handled by the shell-specific class. Pass the completion dictionary and self.app.stdout to CompleteBash or CompleteNoCode and let it do all of the writing. That way, for shells that use a completely different syntax, the output can be controlled in one place.