Ask Your Question
0

What is the method for supplying schema for command arguments in a vscode extension?

asked 2021-08-17 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-08-15 12:00:00 +0000

lakamha gravatar image

The method for supplying schema for command arguments in a vscode extension is by using the args property in the package.json file of the extension.

You can define each argument's name, type, description, required status, default value, and other properties in the args property.

Here's an example:

{
   "contributes": {
      "commands": [
         {
            "command": "myExtension.myCommand",
            "title": "My Command",
            "category": "My Category",
            "description": "Description of my command",
            "args": [
               {
                  "name": "arg1",
                  "type": "string",
                  "description": "Description of arg1",
                  "required": true
               },
               {
                  "name": "arg2",
                  "type": "number",
                  "description": "Description of arg2",
                  "default": 0
               }
            ]
         }
      ]
   }
}

In this example, the myExtension.myCommand command has two arguments: arg1 and arg2. arg1 is a required string argument with a description, while arg2 is an optional number argument with a default value of 0 and a description.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-17 11:00:00 +0000

Seen: 15 times

Last updated: Aug 15 '22