1

for example: when I run the tasks.json:

{
    "tasks": [
     {
        "label": "echo",
        "type": "shell",
        "command": "echo ${workspaceFolder}\\bulid\\${relativeFileDirname}\\${fileBasenameNoExtension}.exe"
     }        
    ],
    "version": "2.0.0"
}

it print

C:\Users\***\OneDrive\***\CLion\bulid\CourseBook\0201_SqList\SqList-main.exe

because my filename was SqList-main.c.

But what I want is Sqlist.exe. Can I do something to let it print?

C:\Users\***\OneDrive\***\CLion\bulid\CourseBook\0201_SqList\SqList.exe

I want a smart or auto method because I have many files to change.

tips: the .c file can not rename for some reason.

1
  • what are your other file names and what needs to be removed Commented Oct 24, 2020 at 10:04

1 Answer 1

1

Using extension Command Variable v1.6.0 there is a command that can transform a number of variables.

For this case you have to modify task.json

{
  "version": "2.0.0",
  "tasks": [
     {
        "label": "echo",
        "type": "shell",
        "command": "echo ${workspaceFolder}\\build\\${relativeFileDirname}\\${input:noMain}.exe"
     }        
  ],
  "inputs": [
    {
      "id": "noMain",
      "type": "command",
      "command": "extension.commandvariable.transform",
      "args": {
        "text": "${fileBasenameNoExtension}",
        "find": "-main"
      }
    }
  ]
}

You can use any regular expression as find and define a replace string with capture group references ($1), and the flags to use to construct the regular expression.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.