Skip to content

Sub Commands

Creating a Sub Commands

In order to create Sub Commands you need to create a parent class command and then create the sub commands as classes that extends SubCommand and finally you need to add the sub commands to the parent command using the @Options decorator.

Let’s check an example. Suppose you have the following directory structure:

  • src
  • Directorycommands
    • Directoryaccount
      • create.command.ts
      • delete.command.ts
      • parent.ts
  • index.ts
  • seyfert.config.js
  • package.json
  • tsconfig.json
import { Declare, Command, Options } from "seyfert";
import { CreateCommand } from "./create.command";
import { DeleteCommand } from "./delete.command";
@Declare({
name: "account",
description: "account command"
})
// Being in the same folder with @AutoLoad() you can save this
@Options([CreateCommand, DeleteCommand])
export class AccountCommand extends Command {}