vscode-coder icon indicating copy to clipboard operation
vscode-coder copied to clipboard

Use cli for all operations instead of the API

Open code-asher opened this issue 1 year ago • 5 comments

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.

code-asher avatar Apr 18 '24 22:04 code-asher

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.

EhabY avatar Nov 10 '25 16:11 EhabY

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.

code-asher avatar Nov 10 '25 20:11 code-asher

Maybe if the cli had a json output format this would be less painful.

code-asher avatar Nov 10 '25 20:11 code-asher

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 :/

EhabY avatar Nov 10 '25 21:11 EhabY

Yeah we just wait for the process to exit and then we would parse the output as JSON.

code-asher avatar Nov 12 '25 19:11 code-asher