Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support createMain(command) return value from run method #97

Open
1 task done
peterroe opened this issue Oct 25, 2023 · 4 comments
Open
1 task done

Support createMain(command) return value from run method #97

peterroe opened this issue Oct 25, 2023 · 4 comments

Comments

@peterroe
Copy link
Contributor

peterroe commented Oct 25, 2023

Describe the feature

import { createMain, defineCommand } from 'citty'

const command = defineCommand({
	//...
	async run() {
		return Promise.resolve("hello")
	}
})

const apiCommand = createMain(_rDefault(command))
 
const value = await apiCommand({
	rawArgs: []
})
console.log(value) //=> "hello"

Additional information

  • Would you be willing to help implement this feature?
@nozomuikuta
Copy link
Member

nozomuikuta commented Oct 25, 2023

Do you mean line 10 looks like below?

const apiCommand = createMain(_rDefault(command))

By the way, this issue would be able to be handled as a part of #94, wouldn't it?
So, let me close this issue and watch #94.

Please reopen this issue if this issue is about different topics.

@pi0 pi0 reopened this Oct 25, 2023
@pi0
Copy link
Member

pi0 commented Oct 25, 2023

Let's keep both open until landing an API that supports both usecases :)

(@nozomuikuta kindly please ping maintainer instead of doing actions like closing issues, i could simply forgot about this issue)

@nozomuikuta
Copy link
Member

I see, thank you for the gentle notice 🙏

@peterroe
Copy link
Contributor Author

Returning a value from the run method will be very useful for API call scenarios. If it proves feasible, I will initiate a PR to implement that. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants