Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 2.3 KB

readme.md

File metadata and controls

42 lines (33 loc) · 2.3 KB

Command-Server

Adds support for running arbitrary commands via file-based RPC. Designed for use with voice-control systems such as Talon.

Note: Initial version of this extension expected files to be in user-temp/visual-studio-CommandServer the main branch of Knausj (The main Talon user configs) uses visual-studio-command-server, if you are no longer receiving commands, check your program is writing commands to user-temp/visual-studio-command-server directory. The user-temp directory is usually C:\Users\your-name\AppData\Local\Temp\

Features

  • On start-up of Visual Studio, creates a communication directory in the users temp directory, called visual-studio-command-server
  • Then waits for the CommandServer.ReceiveCommand command to be issued.
  • Once the server is triggered the command server will read the request.json file in the communication directory.
  • The command in the JSON file is then executed and a response written to response.json. Note that we write the JSON response on a single line, with a trailing newline, so that the client can repeatedly try to read the file until it finds a final newline to indicate that the write is complete.

Note that the command server will refuse to execute a command if the request file is older than 3 seconds.

Requests look as follows:

{
  "commandId": "some-command-id",
  "args": ["some-argument"]
  "uuid": "aguid-aguid-aguid-aguid-aguid"
}
  • The uuid is used by the command server to create the response file so that the system creating the request files can correlate the request.json and response.json files.

  • The command servers default command handler recognises commands which start with an commandId of VSCommand, for example the command file below issues the Find command (similar to pressing ctrl-f), the advantage being that by using the command directly we are not dependant keyboard bindings.

{
  "commandId": "VSCommand",
  "args": [
    "Edit.Find",
    " \\doc"
  ],
  "uuid": "708dfb4c-0f68-4b88-b229-4225d21534fa"
} 
  • The Extension adds a new Output Window which logs data from the extension:
  • For details of adding command handlers for different commands see Contracts