vscode-coder
vscode-coder copied to clipboard
Use cli for all operations instead of the API
We have to re-implement logic (like updating a workspace before starting it) and it would be better to just call out to the cli since it already accounts for all that.
It is a lot of surface area to cover (every plugin) any time a feature is added.
If the command errors, show whatever is in stderr as the error message.
An alternative would be to handle these things at the API layer, and maybe there is a case to be made for that.
I personally see this being handled better by the API because we can pass structured JSON and get back JSON as well, making parsing and evaluating results much simpler (this is a web platform after all). If anything my suggestion is to use the API for everything and try to ditch the CLI because we have to parse STDOUT and STDERR to get useful output from it.
I agree but I think at the moment it is unlikely we move any logic to the API unless someone writes up an RFC for it and champions the change.
Another issue is that some people fork the cli and add things like two factor auth, so we have to spawn the cli for those cases anyway.
Maybe if the cli had a json output format this would be less painful.
Still not ideal since we'd need another system of interceptors and waiting for events based on text output sucks (though I suppose the CLI can exit the process when it's done?). Just seems quirky tbh :/
Yeah we just wait for the process to exit and then we would parse the output as JSON.