Support `setup` to return data
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 58
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Start by tracing the defineCommand lifecycle from setup into run and inspect how arguments are passed to subcommands. Done should mean setup can return context-dependent data and run receives that data, with tests covering the new behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100