Sorry, I still don't understand why that's relavent. It's probably my fault for not being clear enough. Please be patient with me as I try to further elaborate:
If the command is in charge of both generating completions and also for parsing arguments, wouldn't it be aware of all inner-dependencies between flags? Wouldn't such awareness make it possible to generate candidates based on previous flags?
I'm not familiar with ffmpeg, but let's assume that there was another similar program called ggmpeg. Let's assume that it accepts the flag '--input-format' and then either the flag '--repeat-video-range' or '--repeat-image-frames', depending on whether the format is an video or an image.
That is, only the following flag sequences are valid:
ggmpeg --input-format=video/webm --repeat-video-range=.. ...
or ggmpeg --input-format=image/png --repeat-image-frames=.. ...
Let's also assume that ggmpeg signals to the shell that it is responsible for generating its own completions by passing the flag --_completion to it.Now, if the user types the following command
ggmpeg --input-format=image/png --repea[CURSOR]
and then presses tab, thereby invoking the shell's auto completion routine, which in turn ultimately executes "ggmpeg" "--_completion" "--input-format=image/png" "--repea"
wouldn't ggmpeg have all the necessary information to only suggest '--repeat-image-frames' and not '--repeat-video-range'?