Sub-Zero (Sub Commands)
We've covered the basics of creating a command, but what if we want to create a command that has subcommands? For example, we want to create a command with a create subcommand and a delete subcommand. This is where subcommands come into play.
Creating a Subcommand
To create a subcommand, we need to create a new class that extends SubCommand and implement the run method. Then, we need to add the subcommand to the main command.
Let's assume you have the following directory structure:
With this file structure, you can use @Autoload() and Seyfert will automatically add the commands for you.
But make sure to export the subcommands by default.
In the example above, we created a create subcommand and a delete subcommand. Then, we added the subcommands to the main command using the @Options decorator.
Note that we essentially treat the subcommand as an option of the main command. (In fact, this is how Discord handles subcommands too)
Subcommand Groups
For a more divided structure, you can create groups for subcommands using the @Group and @Groups decorators in the main command.