When adding a new command, it should be automatically added to its parent command.
The parent can be specified with a flag, the default will be the root command.
This requires parsing and modifying the AST, which is a bit more involved. https://www.zupzup.org/ast-manipulation-go/ is a nice resource to learn the basics of AST manipulation.