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

Setup a default behavior when no subcommand used #153

Open
1 task done
fu050409 opened this issue Jul 5, 2024 · 1 comment · May be fixed by #156
Open
1 task done

Setup a default behavior when no subcommand used #153

fu050409 opened this issue Jul 5, 2024 · 1 comment · May be fixed by #156
Labels
enhancement New feature or request

Comments

@fu050409
Copy link

fu050409 commented Jul 5, 2024

Describe the feature

Hi! Sometimes, if our CLI tool get no args, it should work the same as one of it's subCommands, like farm and vite, Vite and Farm both open a development server if no args is given. This works the same as farm dev and vite dev.

Now citty will throw an error if there is no args and run function is not defined for main. But if run function for main is defined, and you're using a subcommand, citty will call the run function defined in main repeatly after called run function defined in subCommand. This confused me, I think it shouldn't call the main handler function when using a subcommand.

Therefore, can we provide a api to setup a default bahavior with no subcommand used?

Such as:

subCommands: {
    dev,
},
default: 'dev'

If so, I'd like to work with this issue :)

Additional information

  • Would you be willing to help implement this feature?
@fu050409 fu050409 added the enhancement New feature or request label Jul 5, 2024
fu050409 added a commit to fu050409/citty that referenced this issue Jul 5, 2024
@fu050409 fu050409 linked a pull request Jul 5, 2024 that will close this issue
@zuixinwang
Copy link
Contributor

zuixinwang commented Jul 15, 2024

I think a default subcommand is unnecessary because, without it, the main command would run 👀
Perhaps it's a good idea not to run the run function of the main command when running the sub-command, but compatibility needs to be considered

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

Successfully merging a pull request may close this issue.

2 participants