When I switched from bash(1) to zsh(1), I was surprised to find how many standard programs lacked completion functions. Only few of the coreutils are supported in vanilla zsh(1).
Although there are user-contributed repositories like zsh-users/zsh-completions I still couldn't find completion functions for tools like cat, nl, df and others.
So I wrote some and I've found that I basically just copied the info from help text to the completion function. Boring. Something that even a machine could do. Well, kinda...
Almost every program with command line arguments implements also --help text, which already lists the options even with their description. So why not use that for generating the functions?
... Because every program uses slightly different format and it would be nightmare to cover all the cases, you say? Then you're exactly right. But then I though that I don't anything perfect, just something that mostly works.
Luckily, most programs do play nice. But help texts are still meant to be for humans so sometimes it borks...
Here's a zsh(1) plugin I wrote that does exactly that..