compgen: Add logic to compose the compgen.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>