Skip to content

Support setup to return data #92

@peterroe

Description

@peterroe

Describe the feature

export default defineCommand({
    meta: {
        name: 'test',
        description: 'Test command',
    },
    async setup(context) {
        const data = someComputed(context)
		return { data }
    },
    async run({ args }, { data }) {
		console.log(data)
	}
})

Reason

The return value of setup could be useful, in addition to some initialization behavior, it could potentially produce different values depending on the context, which could be used in setup and passed to all subcommands in the run method arguments!

Of course, I may not have thought this through completely, does anyone else have a better suggestion?

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