Skip to content

Accepting sync and async callbacks while keeping yargs functions sync-only is incoherent #1420

@mleguen

Description

@mleguen

This issue is a follow-up of the discusion with @bcoe and @gajus in #1412

Example with command handlers:

  • at the moment:
    • we accept async handlers for commands
    • we asynchronously log an error in parse() and showHelp() (and maybe other functions as well?) when an async handler reject
    • as parse() and showHelp() are sync, the calling program has no way to know if and when such an error will occur
  • expected behavior:
    • when an async handler needs to be called, the calling Yargs function (parse(), showHelp(), etc.) should return a promise, to be resolved/rejected after the handler completes, for the calling program to know what is happening
    • when the handler is sync, the current behavior should be kept, ie the calling Yargs function should not return a promise

Before opening any PR, please detail in this issue the intended conception for review, and do not limit it to the command handler example detailed here (there may be other cases of async input).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions