I've been working on connecting up the CLI to VSCode, and I'm always using the
--json
argument to ensure I get complete, structured data. In case of errors though, the command output goes to
stderr
instead of
stdout
and is usually (always?) a string instead of json.
I'm hoping for a more stable way to identify these error message types, rather than matching on individual words or phrases that may change in the future. For instance, when publishing a task if there is a conflict I want to detect that and offer to open up the diff editor. But right now, I'm matching on an error string that could change.
Perhaps exiting with standardized error codes? eg.
  • 2
    - remote conflict
  • 3
    - task not found
  • 4
    - auth failure
It looks like
pull
already uses exit code 2 for conflicts, so this system could possibly be expanded to cover to all errors.
I'm not sure if it would make sense to format stderr as json when the
--json
argument is passed, but maybe that's also worth considering.