You can check my listcommands plugin to see how I do it:
https://github.com/corbosman/listcommands/blob/master/listcommands.php
Cor