Skip to content

Support hooks befor/after execute run func #98

@tmg0

Description

@tmg0

Describe the feature

Add defs in defineCommand function like interceptors or middlewares

example:

const customInterceptor1 = (ctx: CommandContext) => false
const customInterceptor2 = (ctx: CommandContext) => console.log('before run.')

defineCommand({
  meta: {
    name: "hello",
    version: "1.0.0",
    description: "My Awesome CLI App",
  },
  interceptors: [customInterceptor1, customInterceptor2]
  run({ args }) {
    // output: before run.
    // and this code will not be execute
    console.log(`${args.friendly ? "Hi" : "Greetings"} ${args.name}!`);
  },
})

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions